-
Notifications
You must be signed in to change notification settings - Fork 20.6k
Data: align data accessors with the ultimate "Embrace HTML5" direction #2257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
- This effectively implements our "Embrace HTML5" option - Related: http://goo.gl/GcQAtn Fixes gh-2257
I thought I had posted a question when I was mobile this morning, but I guess it didn't go through... There is no mention (maybe there is, and I missed it?) of this use case: jQuery("<div>").data({ "a-b": 1 }).data(); // => { "a-b": 1} Which is definitely broken now, but if that was intentional (which is fine, I guess), then it needs to be made really clear in the docs. Undoubtedly, there is code that expects to be able to serialize and deserialize that data without jQuery screwing with it. |
Right, we have intentionally broken this case. We will be covering this in the migrate plugin and docs. |
That said, |
camelCasing in
.data()
has always been problematic. Our attempts to work around camelCasing whenever possible has always caused problems. We've decided to just always camelCase. Not only will our implementation align with the dataset spec, but it makes everything a lot simpler.I've made a separate issue because #1751 is not broad enough in scope. It only pertains to keys with dashes and digits, which will also be fixed, but in a separate commit.
The solution as @gibson042 laid out in this comment, is this...
And per #1515 (comment) , we want the "Embrace HTML5" option:
data-*
attributes into the data object on first access.data( key, val )
(setter).data( obj )
(bulk setter).data( key )
(getter).data()
The text was updated successfully, but these errors were encountered: