Skip to main content

Bug Tracker

Side navigation

#14111 closed bug (notabug)

Opened July 07, 2013 07:21AM UTC

Closed July 08, 2013 01:33PM UTC

.data(obj) sets data in weird way that ignores next .data(key,value) call

Reported by: anonymous Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 2.0.2
Keywords: Cc:
Blocked by: Blocking:

Steps to reproduce:

Go to

Click on the title three times slowly.

The first click should do nothing.

Expected result:

The alerted message should appear on the second click.

Observed result:

The alerted message does not appear until the third click!

The following is the incorrect code:{'foo':false});'foo',true);'foo'); returns false instead of true!!

However if I do either of these two it works great:{'foo':false});'foo',true);'foo',true); Have to assign twice for it to stick..'foo'); returns true

--OR--'foo',false); Don't use .data(obj) and there is no issue!'foo',true);'foo'); //returns true

Attachments (0)
Change History (3)

Changed July 07, 2013 02:10PM UTC by dmethvin comment:1

The examples using "foo" should work with no problem. The issue is that you've used a hyphenated form of a name when setting the data object in the code sample. You always need to use the W3C camelCased form when setting data directly.

It's mentioned here:

Rule: When accessing data taken from data-* attributes, and especially when accessing the data object directly, use the W3C camelCasing conventions. --

Since your call to .data() *explicitly* requests the dashed form, that value is returned to you even though the normalized camelCased value has been changed by a subsequent call.

Changed July 07, 2013 03:21PM UTC by anonymous comment:2

My bad.

Thanks for getting back to me so fast :).

I can't close the ticket, but I feel satisfied that this resolved the issue.

Changed July 08, 2013 01:33PM UTC by timmywil comment:3

resolution: → notabug
status: newclosed