Bug Tracker

Opened 11 years ago

Closed 11 years ago

#10368 closed bug (invalid)

IE's .data() returns empty object

Reported by: [email protected] Owned by: Rick Waldron
Priority: low Milestone: 1.next
Component: data Version: 1.6.4
Keywords: Cc:
Blocked by: Blocking:


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

comment:1 Changed 11 years ago by dmethvin

Owner: set to [email protected]
Status: newpending

That's correct, see item 5 here:


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.

comment:2 Changed 11 years ago by Rick Waldron

Component: unfileddata
Keywords: needsdocs added
Milestone: None1.next
Priority: undecidedlow

Simply put, you're asking for invalid property identifiers... See: http://jsfiddle.net/rwaldron/qmLdX/

comment:3 Changed 11 years ago by [email protected]

Status: pendingnew

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 11 years ago by Rick Waldron

Keywords: needsdocs removed
Owner: changed from [email protected] to Rick Waldron
Status: newassigned

comment:5 Changed 11 years ago by Rick Waldron

Resolution: invalid
Status: assignedclosed

"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)

Note: See TracTickets for help on using tickets.