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

Check .hasAttribute() in prefer-dom-node-dataset rule #1669

Closed
fisker opened this issue Dec 29, 2021 · 1 comment · Fixed by #1673
Closed

Check .hasAttribute() in prefer-dom-node-dataset rule #1669

fisker opened this issue Dec 29, 2021 · 1 comment · Fixed by #1673

Comments

@fisker
Copy link
Collaborator

fisker commented Dec 29, 2021

MDN suggest using in operator to check existence, I'm not sure what's the best, maybe hasOwnProperty()?

Fail

element.hasAttribute('data-foo');

Pass

"foo" in element.dataset;
@sindresorhus
Copy link
Owner

Yes, it should recommend .hasOwnProperty(). We can add a code TODO comment to switch to Object.hasOwn later on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants