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

Custom data attributes are not correctly converted to properties #19

Closed
martypdx opened this issue Jan 4, 2024 · 1 comment
Closed

Comments

@martypdx
Copy link

martypdx commented Jan 4, 2024

Given:

<p data-title="my paragraph">text</p>

Current behavior reports property as dataTitle which will not work against the dom element to access or set the value. Correct access is through p.dataset.title. While there are tests, the tested behavior is incorrect for web standard platform.

Custom data attributes (data-*) appear on the corresponding element as camelCase sub-properties of element.dataset

Given how the rest of library is structured, my suggestion would be to add a .dataset = true to info and object report the property without the data- prefix.

LMK if I am misunderstanding the purpose of this library. I'm going off the first line that intent is to be web standard:

Info on the properties and attributes of the web platform

Also happy to make PRs if I can help

@martypdx martypdx closed this as completed Jan 5, 2024
@wooorm
Copy link
Owner

wooorm commented Jan 5, 2024

In this project, property does not reflect DOM Web IDL properties, because the DOM does not reflect all attributes, and sometimes uses inconsistent casing. For more info, see #18 (comment). And, I’d recommend https://github.com/syntax-tree/hast-util-to-dom, if you want to turn hast into DOM nodes.

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

No branches or pull requests

2 participants