Skip to main content

Bug Tracker

Side navigation

#1908 closed bug (fixed)

Opened November 09, 2007 08:05PM UTC

Closed November 28, 2007 11:55PM UTC

Last modified October 14, 2008 10:34AM UTC

jQuery.extend(true,{foo:"bar"},{foo:null}); //throws an exception

Reported by: cthatcher Owned by:
Priority: major Milestone: 1.2.2
Component: core Version: 1.2.1
Keywords: extend null TypeError: Cannot read property "nodeType" from null Cc:
Blocked by: Blocking:
Description

When running my unit tests in the jQuery testing harness (a few days old from svn) I found that

jQuery.extend(true,{foo:"bar"},{foo:null});

will throw an exception with the message:

TypeError: Cannot read property "nodeType" from null

I believe that jQuery.extend is missing a test for this, so I changed

Recurse if we're merging object values

if ( deep && typeof options[ name ] == "object" && target[ name ] && !options[ name ].nodeType )

to

Recurse if we're merging object values

if ( deep && options[ name ] && typeof options[ name ] == "object" && target[ name ] && !options[ name ].nodeType )

and everything works as intended. I guess that this is supposed to be included in the test ' typeof options[ name ] == "object" ', but the following test cases illustrate this isnt quite enough since:

equals( false, (typeof null == "object"), "null is an object?");

equals( false, (typeof null === "object"), "null is an object?");

yield

[java] FAIL (114) [claypool.application] null is an object? expected: false actual: true

[java] FAIL (115) [claypool.application] null is an object? expected: false actual: true

Attachments (0)
Change History (1)

Changed November 28, 2007 11:55PM UTC by davidserduke comment:1

resolution: → fixed
status: newclosed

Fixed in [3972]. Backed out one of the changes in [3973] that was more of a design issue and I decided I should have left it alone.