Skip to main content

Bug Tracker

Side navigation

#8047 closed bug (invalid)

Opened January 25, 2011 09:35AM UTC

Closed January 26, 2011 04:54PM UTC

Last modified February 09, 2011 09:41PM UTC

.data function bug

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

It illustraed on jsfiddle :

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.

Attachments (0)
Change History (6)

Changed January 25, 2011 02:02PM UTC by rwaldron comment:1

owner: →
status: newpending

Please file a separate ticket for the ajax error.

Changed January 25, 2011 02:04PM UTC by rwaldron comment:2

component: unfileddata

Changed January 26, 2011 04:54PM UTC by jitter comment:3

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().

Changed January 26, 2011 05:06PM UTC by comment:4

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.

Changed January 28, 2011 01:11PM UTC by jitter comment:5

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.

Changed February 09, 2011 09:41PM UTC by BorisMoore comment:6

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.