Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 10 years ago

#11746 closed bug (invalid)

$().data() return undefined if name contains uppercase

Reported by: quaff Owned by:
Priority: low Milestone: None
Component: data Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:

Change History (5)

comment:1 Changed 11 years ago by sindresorhus

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

That's because it doesn't find the data-attribute. Data-attributes are automatically lowercased by the browser.

HTML5 spec:

All attributes on HTML elements in HTML documents get ASCII-lowercased automatically

comment:2 Changed 11 years ago by quaff

should jquery auto lowercase and keep correspondence with html5 spec?

comment:3 Changed 11 years ago by dmethvin

Nope, if you want mixed case you use the "-" character. Please read these, and followup with a forum post if needed:



Last edited 11 years ago by dmethvin (previous) (diff)

comment:4 Changed 10 years ago by [email protected]

Would be nice if this was explained as a note in the docs so we know where to start looking.

comment:5 Changed 10 years ago by dmethvin

The linked article about data APIs goes into plenty of detail, and says this:

Rule: When accessing data taken from data-* attributes, and especially when accessing the data object directly, use the W3C camelCasing conventions.

In any documentation there will be a tradeoff between describing every detail in every situation on every API where it can arise versus making the documentation readable and comprehensible.

Note: See TracTickets for help on using tickets.