mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Fix for bug #1546 where a deep copy was attempted of DOM elements (which isn't needed).
This commit is contained in:
parent
9ac9aaeec3
commit
14b88f6019
@ -534,7 +534,7 @@ jQuery.extend = jQuery.fn.extend = function() {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Recurse if we're merging object values
|
// 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 ] );
|
jQuery.extend( target[ name ], options[ name ] );
|
||||||
|
|
||||||
// Don't bring in undefined values
|
// Don't bring in undefined values
|
||||||
|
@ -778,7 +778,7 @@ test("is(String)", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("$.extend(Object, Object)", function() {
|
test("$.extend(Object, Object)", function() {
|
||||||
expect(10);
|
expect(11);
|
||||||
|
|
||||||
var settings = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
|
var settings = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
|
||||||
options = { xnumber2: 1, xstring2: "x", xxx: "newstring" },
|
options = { xnumber2: 1, xstring2: "x", xxx: "newstring" },
|
||||||
@ -786,9 +786,9 @@ test("$.extend(Object, Object)", function() {
|
|||||||
merged = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "x", xxx: "newstring" },
|
merged = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "x", xxx: "newstring" },
|
||||||
deep1 = { foo: { bar: true } },
|
deep1 = { foo: { bar: true } },
|
||||||
deep1copy = { foo: { bar: true } },
|
deep1copy = { foo: { bar: true } },
|
||||||
deep2 = { foo: { baz: true } },
|
deep2 = { foo: { baz: true }, foo2: document },
|
||||||
deep2copy = { foo: { baz: true } },
|
deep2copy = { foo: { baz: true }, foo2: document },
|
||||||
deepmerged = { foo: { bar: true, baz: true } };
|
deepmerged = { foo: { bar: true, baz: true }, foo2: document };
|
||||||
|
|
||||||
jQuery.extend(settings, options);
|
jQuery.extend(settings, options);
|
||||||
isObj( settings, merged, "Check if extended: settings must be extended" );
|
isObj( settings, merged, "Check if extended: settings must be extended" );
|
||||||
@ -801,6 +801,7 @@ test("$.extend(Object, Object)", function() {
|
|||||||
jQuery.extend(true, deep1, deep2);
|
jQuery.extend(true, deep1, deep2);
|
||||||
isObj( deep1.foo, deepmerged.foo, "Check if foo: settings must be extended" );
|
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" );
|
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" },
|
var defaults = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
|
||||||
defaultsCopy = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
|
defaultsCopy = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
|
||||||
|
Loading…
Reference in New Issue
Block a user