Bug Tracker

Opened 12 years ago

Closed 12 years ago

Last modified 11 years ago

#1908 closed bug (fixed)

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

Change History (1)

comment:1 Changed 12 years ago by davidserduke

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.

Note: See TracTickets for help on using tickets.