Opened 13 years ago
Closed 12 years ago
#5427 closed bug
$.extend(false, target, obj) doesn't extend target itself
Reported by: | gminuses | Owned by: | gminuses |
---|---|---|---|
Priority: | low | Milestone: | 1.4 |
Component: | core | Version: | 1.3.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
After executing the following code:
var target = { a: 1 }; $.extend(false, target, { a: 2 });
target is still { a: 1 };
$.extend incorrectly finds target in its definition:
{} |
Handle a deep copy situation
if ( typeof target === "boolean" ) {
deep = target;
target = arguments[1] {}; skip the boolean and the target i = 2;
}
Change History (4)
comment:1 Changed 13 years ago by
comment:2 Changed 13 years ago by
It can be easily fixed by just removing "||
{}":
var target = arguments[0], ...
The validation of target will be checked in its following code:
if ( typeof target !== "object" && !jQuery.isFunction(target) ) target = {};
comment:3 Changed 12 years ago by
Owner: | set to gminuses |
---|---|
Priority: | major → low |
Status: | new → pending |
Please distill this into a reduced test case on jsFiddle, thanks
comment:4 Changed 12 years ago by
Status: | pending → closed |
---|
Automatically closed due to 14 days of inactivity.
Note: See
TracTickets for help on using
tickets.
It has line-breaking issues, repost:
After executing the following code:
target is still { a: 1 };
$.extend incorrectly finds target in its definition: