Two quick fixes in relation to #1028. ajaxSetup shouldn't be deep and the boolean...
[jquery.git] / src / jquery / jquery.js
index 5ffccc5..1d2e197 100644 (file)
@@ -301,7 +301,7 @@ jQuery.fn = jQuery.prototype = {
         */
        setArray: function( a ) {
                this.length = 0;
-               [].push.apply( this, a );
+               Array.prototype.push.apply( this, a );
                return this;
        },
 
@@ -1256,7 +1256,13 @@ jQuery.fn = jQuery.prototype = {
  */
 jQuery.extend = jQuery.fn.extend = function() {
        // copy reference to target object
-       var target = arguments[0] || {}, a = 1, al = arguments.length;
+       var target = arguments[0] || {}, a = 1, al = arguments.length, deep = false;
+
+       // Handle a deep copy situation
+       if ( target.constructor == Boolean ) {
+               deep = target;
+               target = arguments[1] || {};
+       }
 
        // extend jQuery itself if only one argument is passed
        if ( al == 1 ) {
@@ -1276,7 +1282,7 @@ jQuery.extend = jQuery.fn.extend = function() {
                                        continue;
 
                                // Recurse if we're merging object values
-                               if ( typeof prop[i] == 'object' && target[i] )
+                               if ( deep && typeof prop[i] == 'object' && target[i] )
                                        jQuery.extend( target[i], prop[i] );
 
                                // Don't bring in undefined values
@@ -1391,17 +1397,23 @@ jQuery.extend({
         */
        // args is for internal usage only
        each: function( obj, fn, args ) {
-               if ( obj.length == undefined )
-                       for ( var i in obj )
-                               fn.apply( obj[i], args || [i, obj[i]] );
-               else if ( args ) {
-                       for ( var i = 0, ol = obj.length; i < ol; i++ )
-                               if ( fn.apply( obj[i], args ) === false ) break;
+               if ( args ) {
+                       if ( obj.length == undefined )
+                               for ( var i in obj )
+                                       fn.apply( obj[i], args );
+                       else
+                               for ( var i = 0, ol = obj.length; i < ol; i++ )
+                                       if ( fn.apply( obj[i], args ) === false ) break;
 
                // A special, fast, case for the most common use of each
-               } else
-                       for ( var i = 0, ol = obj.length, val = obj[0]; 
-                               i < ol && fn.call(val,i,val) !== false; val = obj[++i] );
+               } else {
+                       if ( obj.length == undefined )
+                               for ( var i in obj )
+                                       fn.call( obj[i], i, obj[i] );
+                       else
+                               for ( var i = 0, ol = obj.length, val = obj[0]; 
+                                       i < ol && fn.call(val,i,val) !== false; val = obj[++i] );
+               }
 
                return obj;
        },