Added in jQuery.isFunction().
[jquery.git] / src / jquery / jquery.js
index f942bf4..db65cfb 100644 (file)
@@ -33,7 +33,7 @@ var jQuery = function(a,c) {
        // HANDLE: $(function)
        // Shortcut for document ready
        // Safari reports typeof on DOM NodeLists as a function
-       if ( typeof a == "function" && !a.nodeType && a[0] == undefined )
+       if ( isFunction(a) && !a.nodeType && a[0] == undefined )
                return new jQuery(document)[ jQuery.fn.ready ? "ready" : "load" ]( a );
        
        // Handle HTML strings
@@ -864,7 +864,7 @@ jQuery.fn = jQuery.prototype = {
         */
        filter: function(t) {
                return this.pushStack(
-                       t.constructor == Function &&
+                       isFunction( t.constructor ) &&
                        jQuery.grep(this, function(el, index){
                                return t.apply(el, [index])
                        }) ||
@@ -925,7 +925,7 @@ jQuery.fn = jQuery.prototype = {
 
                        jQuery.grep(this,function(a){
                                        if ( t.constructor == Array || t.jquery )
-                                               return !jQuery.inArray( t, a );
+                                               return jQuery.inArray( t, a ) < 0;
                                        else
                                                return a != t;
                        }) );
@@ -1212,6 +1212,10 @@ jQuery.extend({
                        $ = jQuery._$;
        },
 
+       isFunction: function( fn ) {
+               return fn && typeof fn == "function";
+       },
+
        /**
         * A generic iterator function, which can be used to seemlessly
         * iterate over both objects and arrays. This function is not the same
@@ -1253,7 +1257,7 @@ jQuery.extend({
        
        prop: function(elem, value, type){
                        // Handle executable functions
-                       if ( value.constructor == Function )
+                       if ( isFunction( value ) )
                                return value.call( elem );
 
                        // Handle passing in a number to a CSS property
@@ -1386,6 +1390,11 @@ jQuery.extend({
 
                for ( var i = 0, al = a.length; i < al; i++ ) {
                        var arg = a[i];
+
+                       if ( !arg ) continue;
+
+                       if ( arg.constructor == Number )
+                               arg = arg.toString();
                        
                         // Convert html string into DOM nodes
                        if ( typeof arg == "string" ) {
@@ -1699,7 +1708,7 @@ jQuery.extend({
  */
  
 /*
- * Wheather the W3C compliant box model is being used.
+ * Whether the W3C compliant box model is being used.
  *
  * @property
  * @name $.boxModel