Bug Tracker

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#8047 closed bug (invalid)

.data function bug

Reported by: fddima@… Owned by: fddima@…
Priority: low Milestone: 1.5
Component: data Version: 1.5rc1
Keywords: Cc:
Blocked by: Blocking:


It illustraed on jsfiddle http://jsfiddle.net/ZagJA/ :

var q = { boolField: true };
$(q).data("boolField", "true");

this code on 1.4.4 or 1.5 beta 1 produce result:


but in on 1.5 RC 1 it is produce:


this is wrong...

PS: Also 1.5RC1 ajax with 'json' request/response type return parseerror on valid json.

Change History (6)

comment:1 Changed 9 years ago by Rick Waldron

Owner: set to fddima@…
Status: newpending

Please file a separate ticket for the ajax error.

comment:2 Changed 9 years ago by Rick Waldron

Component: unfileddata

comment:3 Changed 9 years ago by jitter

Milestone: 1.next1.5
Priority: undecidedlow
Resolution: invalid
Status: pendingclosed

Thanks for taking the time to contribute to the jQuery project by writing a bug report.

This isn't a bug but the intended behavior.

Actually the behavior introduced with 1.4.3 was a regression compared to the behavior of earlier jquery versions. In jQuery 1.4.3/1.4.4 .data() on a plain js object did a destructive operation, in the sense that it overwrote existing properties.

You can compare the behavior of jQuery over different versions with this test case. This test shows how the behavior in 1.4.3/1.4.4 has unwanted side-effects.

If you want to change properties directly on an object its much easier and faster to do q.boolField = something instead of using .data().

comment:4 Changed 9 years ago by fddima@…

Uff... Thanks for explain!

Note: Current version of jquery.datalink plugin designed for version 1.4.3 (works both with 1.4.4 and 1.5b1), uses .data() method for changing object properties (with events). But, of course, this is issue of datalink plugin.

comment:5 Changed 9 years ago by jitter

afaik this is known to the datalink team. datalink is still in beta and likely to undergo structural changes in which problems like this are surely going to be addressed.

comment:6 Changed 9 years ago by BorisMoore

Current datalink builds provide the .setField() method to use, rather than .data(). However the problem of serialization of the object being broken unfortunately remains, and is not due to datalink itself. It is independent of datalink.

Note: See TracTickets for help on using tickets.