Ticket #10368 (closed bug: invalid)
IE's .data() returns empty object
| Reported by: | psayre@… | Owned by: | rwaldron |
|---|---|---|---|
| Priority: | low | Milestone: | 1.next |
| Component: | data | Version: | 1.6.4 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
It looks like there is a regression in 1.6.4 jQuery. Calling $('div').data() on <div data-elem-ID="HTML"></div> returns an empty object.
Change History
comment:1 Changed 21 months ago by dmethvin
- Owner set to psayre@…
- Status changed from new to pending
comment:2 Changed 21 months ago by rwaldron
- Keywords needsdocs added
- Priority changed from undecided to low
- Component changed from unfiled to data
- Milestone changed from None to 1.next
Simply put, you're asking for invalid property identifiers... See: http://jsfiddle.net/rwaldron/qmLdX/
comment:3 Changed 21 months ago by psayre@…
- Status changed from pending to new
No, you are missing the point. I discovered a regression while researching a browser inconsistency. It is not a documentation issue.
If you load this in FF and IE, they will give different results (using jQuery 1.6.3). This is what I was researching. http://jsfiddle.net/qmLdX/2/
But, while doing that research, I found IE doesn't give _any_ data (using jQuery edge). This is the bug I am reporting. http://jsfiddle.net/qmLdX/3/
comment:4 Changed 21 months ago by rwaldron
- Keywords needsdocs removed
- Owner changed from psayre@… to rwaldron
- Status changed from new to assigned
comment:5 Changed 21 months ago by rwaldron
- Status changed from assigned to closed
- Resolution set to invalid
"data-elem-ID" is an _invalid_ attribute. See: http://www.w3.org/TR/html5/elements.html#embedding-custom-non-visible-data-with-the-data-attributes
A custom data attribute is an attribute in no namespace whose name starts with the string "data-", has at least one character after the hyphen, is XML-compatible, and contains no characters in the range U+0041 to U+005A (LATIN CAPITAL LETTER A to LATIN CAPITAL LETTER Z).
Correct: http://jsfiddle.net/rwaldron/qmLdX/8/embedded/result/ (works in all IEs)
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

That's correct, see item 5 here:
http://www.learningjquery.com/2011/09/using-jquerys-data-apis
If you access the properties via .data() it should still be possible to get them consistently across different versions, only the internal representation has changed so we could be compliant with the way the W3C wants it.
What should we add to the documentation at http://api.jquery.com/data/ to clarify the issue? Looks like we don't have an example with a dash, which would probably help.