Ticket #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: | ||
| Blocking: | Blocked by: |
Description
Change History
comment:1 Changed 13 months ago by sindresorhus
- Priority changed from undecided to low
- Resolution set to invalid
- Status changed from new to closed
- Component changed from unfiled to data
comment:2 Changed 13 months ago by quaff
should jquery auto lowercase and keep correspondence with html5 spec?
comment:3 Changed 13 months ago by dmethvin
Nope, if you want mixed case you use the "-" character. Please read these, and followup with a forum post if needed:
http://www.learningjquery.com/2011/09/using-jquerys-data-apis
comment:4 Changed 9 months ago by verheyen.koen@…
Would be nice if this was explained as a note in the docs so we know where to start looking.
comment:5 Changed 9 months 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.
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 because it doesn't find the data-attribute. Data-attributes are automatically lowercased by the browser.
HTML5 spec: