Modify ↓
Ticket #5306 (closed bug: fixed)
$.isObject() is incorrect, and in some cases will cause $.extend() malfunctions
| Reported by: | Tony Chen | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 1.4 |
| Component: | core | Version: | |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
code:
x = { a:{ a1:1, a2:2 }, b:2 };
y = { a:{ a3:3 }, c:3 };
console.log("x is ",JSON.stringify(x));
console.log("y is ",JSON.stringify(y));
console.log("$.isObject(x) is ",$.isObject(x))
z = $.extend(true,{}, x, y);
console.log("execut: z = $.extend(true,{}, x, y);");
console.log("x is ",JSON.stringify(x)," <--should not be changed!");
output:
x is {"a":{"a1":1,"a2":2},"b":2}
y is {"a":{"a3":3},"c":3}
$.isObject(x) is false
execut: z = $.extend(true,{}, x, y);
x is {"a":{"a1":1,"a2":2,"a3":3},"b":2} <-- should not be changed!
Change History
comment:2 Changed 4 years ago by john
- Status changed from new to closed
- Resolution set to fixed
This should be fixed in this recent commit: http://github.com/jquery/jquery/commit/c2bbcd88335cf6f8df4ac9389ecbae90291377fb
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

From revision 6442 up to 6586