Skip to content
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

$(el).data() calls break due to camelCase conversion #436

Open
liady opened this issue Jun 24, 2021 · 1 comment
Open

$(el).data() calls break due to camelCase conversion #436

liady opened this issue Jun 24, 2021 · 1 comment
Assignees
Labels
Milestone

Comments

@liady
Copy link

liady commented Jun 24, 2021

Currently this migration script fixes only $.data() calls, but $.fn.data still have the incompatibility with automatic camelCase conversion.

// el: <div data-my-prop=test />
var data = $(el).data();
// data: {myProp: 'test'}
assert(data['my-prop']===test) // works on jQuery v2, fails on v3
liady added a commit to liady/jquery-migrate that referenced this issue Jun 24, 2021
When calling `$(el).data()`, the received object contains camel-cased keys, this fixes issue jquery#436
@mgol mgol added this to the 3.3.3 milestone Dec 2, 2021
@mgol mgol modified the milestones: 3.4.1, 3.5.0 Feb 23, 2023
@mgol mgol self-assigned this Oct 9, 2024
@mgol
Copy link
Member

mgol commented Jan 12, 2025

I have a PR adding patches for $.fn.data, but I've just realized it doesn't change the behavior of the shared code snippet. However, neither jQuery 1 nor jQuery 2 behave in that way either! data-* attribute names are camelcased in the data object.

@liady you may not remember the context after all this time, but if you do, can you explain how you got this result?

@mgol mgol added the 3.x-only label Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants