Bug Tracker

Modify

Ticket #11746 (closed bug: invalid)

Opened 2 years ago

Last modified 20 months ago

$().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:

Change History

comment:1 Changed 2 years 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

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 2 years ago by quaff

should jquery auto lowercase and keep correspondence with html5 spec?

comment:3 Changed 2 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:

 http://www.learningjquery.com/2011/09/using-jquerys-data-apis

 http://api.jquery.com/data/

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

comment:4 Changed 20 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 20 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.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.