Bug Tracker

Opened 12 years ago

Closed 12 years ago

#8986 closed bug (worksforme)

element.data() returns undefined for given key!

Reported by: zeljko Owned by:
Priority: low Milestone: 1.next
Component: data Version: git
Keywords: Cc:
Blocked by: Blocking:





Function .data() returns undefined for given key (see fiddle). With jQuery ver <= 1.5.2 everything works as expected.

Change History (3)

comment:1 Changed 12 years ago by dmethvin

Yes, that's working correctly and we did fix a bug in 1.5.2 that alters the behavior. See this test case for clarification: http://jsfiddle.net/ZeSpD/1/

Here is the relevant W3C spec: http://www.w3.org/TR/html5/elements.html#embedding-custom-non-visible-data-with-the-data-attributes

So "testkey" matches data-testkey, data-TESTKEY, data-testKey, etc. On the other hand, "testKey" matches data-test-key, data-test-Key, etc.

I'm leaving the ticket open for now to see if there are significant regressions reported.

Version 0, edited 12 years ago by dmethvin (next)

comment:2 Changed 12 years ago by zeljko

Thanks. All clear now. It's best to avoid camel case data attributes in html.

comment:3 Changed 12 years ago by addyosmani

Component: unfileddata
Priority: undecidedlow
Resolution: worksforme
Status: newclosed

Closing as the original reporter is now clear on the actual behavior in 1.6. As we regularly monitor tickets which are re-opened or have new comments posted, should regressions be posted on this ticket we can re-open the ticket on reviewing, if they are valid.

Note: See TracTickets for help on using tickets.