diff options
author | John Resig <jeresig@gmail.com> | 2007-08-21 04:42:31 +0000 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2007-08-21 04:42:31 +0000 |
commit | e112e6b04d1736d3a847d44b96f7178175e17a15 (patch) | |
tree | 8002efee55d2a982fc9f262a8ba3e01b6ebe589d /src/jquery/jquery.js | |
parent | 8cf5d2df19d918bb84f4c59bc4346c215fbfaf88 (diff) | |
download | jquery-e112e6b04d1736d3a847d44b96f7178175e17a15.tar.gz jquery-e112e6b04d1736d3a847d44b96f7178175e17a15.zip |
Make deep .extend() an optional argument - it will go deep if you pass in an boolean as the first argument (fixed bug #1028).
Diffstat (limited to 'src/jquery/jquery.js')
-rw-r--r-- | src/jquery/jquery.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index 797280e07..a79b2e6b2 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -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 = true; + 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 |