X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fjquery%2Fjquery.js;h=1d2e197970b002b31219ac29ca4066dc4913e1b6;hb=8c15e852a4614ba5a5100e1c6e8a833c39b4ca79;hp=5ffccc5b6c290a879d5c090afce499f7ec006a9e;hpb=f0353e89abf6643e5a88a649887a71a9ebd973d9;p=jquery.git diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index 5ffccc5..1d2e197 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -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; },