]> source.dussan.org Git - jquery.git/commitdiff
Fixed #1908 by testing to make sure it isn't null before checking the nodeType.
authorDavid Serduke <davidserduke@gmail.com>
Wed, 28 Nov 2007 23:42:16 +0000 (23:42 +0000)
committerDavid Serduke <davidserduke@gmail.com>
Wed, 28 Nov 2007 23:42:16 +0000 (23:42 +0000)
src/core.js
test/unit/core.js

index 39aa65be4523d9d2fa41275384bd4ff28df2e19b..4c12150dbb1dc239ca31482b8f636b0f77544e84 100644 (file)
@@ -549,11 +549,11 @@ jQuery.extend = jQuery.fn.extend = function() {
                                        continue;
 
                                // Recurse if we're merging object values
-                               if ( deep && typeof options[ name ] == "object" && target[ name ] && !options[ name ].nodeType )
+                               if ( deep && options[ name ] && typeof options[ name ] == "object" && target[ name ] && !options[ name ].nodeType )
                                        target[ name ] = jQuery.extend( target[ name ], options[ name ] );
 
                                // Don't bring in undefined values
-                               else if ( options[ name ] != undefined )
+                               else if ( options[ name ] !== undefined )
                                        target[ name ] = options[ name ];
 
                        }
index f77d1f8970106160bf1f0153ef59ddf59f578626..f03930413d42d2426d53634bb55b10537f41e198 100644 (file)
@@ -837,7 +837,7 @@ test("is(String)", function() {
 });
 
 test("$.extend(Object, Object)", function() {
-       expect(14);
+       expect(15);
 
        var settings = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
                options =     { xnumber2: 1, xstring2: "x", xxx: "newstring" },
@@ -873,6 +873,9 @@ test("$.extend(Object, Object)", function() {
        var ret = jQuery.extend(true, { foo: "1,2,3" }, { foo: [1, 2, 3] } );
        ok( typeof ret.foo != "string", "Check to make sure values equal with coersion (but not actually equal) overwrite correctly" );
 
+       var ret = jQuery.extend(true, { foo:"bar" }, { foo:null } );
+       equals( ret.foo, null, "Check to make sure values equal with coersion (but not actually equal) overwrite correctly" );
+
        var defaults = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
                defaultsCopy = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
                options1 =     { xnumber2: 1, xstring2: "x" },