Bug Tracker

Opened 7 years ago

Closed 7 years ago

#12270 closed enhancement (duplicate)

Unify .data() with HTML5 data attribute.

Reported by: mstefanow@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:

Description

http://i273.photobucket.com/albums/jj226/stefek99/ScreenShot2012-08-12at133742.png

http://api.jquery.com/data/#data-html5 "As of jQuery 1.4.3 HTML 5 data- attributes will be automatically pulled in to jQuery's data object. '

How about other way round? Enabling .data("value", "param") to be available outside of jQuery?

See the top comments by Ryan Kinal: "It would be awesome if it were the element instead, but that is not the case."

Change History (3)

comment:1 Changed 7 years ago by scottgonzalez

Why not just set the data- attribute if that's what you want? Attributes can only store strings, while .data() can store any type of value.

comment:2 in reply to:  1 Changed 7 years ago by anonymous

Replying to scott.gonzalez:

Why not just set the data- attribute if that's what you want? Attributes can only store strings, while .data() can store any type of value.

Just saying that for string-only values jQuery can serve two way compatibility.

Posted as an "enhancement" for a discussion.

comment:3 Changed 7 years ago by Rick Waldron

Resolution: duplicate
Status: newclosed

Reading is cheap, writing is not. data() precedes "data-*" and has semantics of its own to consider. Also this is probably a duplicate, but I can't find the original.

Note: See TracTickets for help on using tickets.