Skip to main content

Bug Tracker

Side navigation

#10368 closed bug (invalid)

Opened September 28, 2011 05:13PM UTC

Closed September 28, 2011 06:53PM UTC

IE's .data() returns empty object

Reported by: psayre@sitecrafting.com Owned by: rwaldron
Priority: low Milestone: 1.next
Component: data Version: 1.6.4
Keywords: Cc:
Blocked by: Blocking:
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.

http://jsfiddle.net/XcD8m/

Attachments (0)
Change History (5)

Changed September 28, 2011 05:44PM UTC by dmethvin comment:1

owner: → psayre@sitecrafting.com
status: newpending

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.

Changed September 28, 2011 06:18PM UTC by rwaldron comment:2

component: unfileddata
keywords: → needsdocs
milestone: None1.next
priority: undecidedlow

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

Changed September 28, 2011 06:26PM UTC by psayre@sitecrafting.com comment:3

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/

Changed September 28, 2011 06:49PM UTC by rwaldron comment:4

keywords: needsdocs
owner: psayre@sitecrafting.comrwaldron
status: newassigned

Changed September 28, 2011 06:53PM UTC by rwaldron comment:5

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)