Skip to content
Permalink
Browse files

Fix for bug #1546 where a deep copy was attempted of DOM elements (wh…

…ich isn't needed).
  • Loading branch information
jeresig committed Oct 17, 2007
1 parent 9ac9aae commit 14b88f6019cd467c35a2c9e845740a61c153525e
Showing with 6 additions and 5 deletions.
  1. +1 −1 src/core.js
  2. +5 −4 test/unit/core.js
@@ -534,7 +534,7 @@ jQuery.extend = jQuery.fn.extend = function() {
continue;

// Recurse if we're merging object values
if ( deep && typeof options[ name ] == "object" && target[ name ] )
if ( deep && typeof options[ name ] == "object" && target[ name ] && !options[ name ].nodeType )
jQuery.extend( target[ name ], options[ name ] );

// Don't bring in undefined values
@@ -778,17 +778,17 @@ test("is(String)", function() {
});

test("$.extend(Object, Object)", function() {
expect(10);
expect(11);

var settings = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
options = { xnumber2: 1, xstring2: "x", xxx: "newstring" },
optionsCopy = { xnumber2: 1, xstring2: "x", xxx: "newstring" },
merged = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "x", xxx: "newstring" },
deep1 = { foo: { bar: true } },
deep1copy = { foo: { bar: true } },
deep2 = { foo: { baz: true } },
deep2copy = { foo: { baz: true } },
deepmerged = { foo: { bar: true, baz: true } };
deep2 = { foo: { baz: true }, foo2: document },
deep2copy = { foo: { baz: true }, foo2: document },
deepmerged = { foo: { bar: true, baz: true }, foo2: document };

jQuery.extend(settings, options);
isObj( settings, merged, "Check if extended: settings must be extended" );
@@ -801,6 +801,7 @@ test("$.extend(Object, Object)", function() {
jQuery.extend(true, deep1, deep2);
isObj( deep1.foo, deepmerged.foo, "Check if foo: settings must be extended" );
isObj( deep2.foo, deep2copy.foo, "Check if not deep2: options must not be modified" );
equals( deep1.foo2, document, "Make sure that a deep clone was not attempted on the document" );

var defaults = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
defaultsCopy = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },

0 comments on commit 14b88f6

Please sign in to comment.
You can’t perform that action at this time.