Skip to main content

Bug Tracker

Side navigation

#8986 closed bug (worksforme)

Opened April 27, 2011 09:11AM UTC

Closed April 28, 2011 09:12PM UTC

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:
Description

Fiddle:

http://jsfiddle.net/ZeSpD/

Description:

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

Attachments (0)
Change History (3)

Changed April 27, 2011 02:28PM UTC by dmethvin comment:1

_comment0: 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. \ 1303915065301426

Yes, that's working correctly and we did fix a bug in 1.6 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.

Changed April 27, 2011 03:08PM UTC by zeljko comment:2

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

Changed April 28, 2011 09:12PM UTC by addyosmani comment:3

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.