-
Notifications
You must be signed in to change notification settings - Fork 8
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
Native support for attributes #6
Comments
Have you tried 'h("div", { attributes: { foo: "bar" } })' |
Just tried it, didn't work. Looks like setting attributes must go through Node.setAttribute(), Node.attributes has been removed from the spec and Mozilla removed their implementation as well. |
The deprecation notice was a notice of it not working for |
@aghassemi your right, attributes is a read only object as per the spec. We don't have any way to set attributes without using hooks. @aghassemi did you know what most attributes have a property alternative interface. |
@Raynos Right, it's there but can't be set directly without using setAttribute. Most attributes do have corresponding properties, but there are important ones that don't, like ARIA which is crucial for accessibility. so
doesn't work but
does. (tested with Chrome + Vox) Another place where properties vs attributes distinction becomes obvious is CSS attribute selector for custom attributes, a css role like:
doesn't apply to:
but does apply to
Would use of a hook like the attributeHook cause the dom to be always patched when vdiff happens? If so, that could be another good reason to support attributes naively in vdom. |
cc @Matt-Esch |
i'm also wondering about this, as i want to start making my virtualdom components conform to ARIA. +1 to it's also an important issue if we want to be able to stringify vtrees with ARIA attributes into html, which is a requirement for virtualdom components to be accessible without client-side javascript. |
Looks like Matt-Esch/virtual-dom now supports attributes. Thanks! Closing this issue. |
It would be nice to have first-class support for attributes on vNodes even-though attributeHook is a pretty straightforward work-around and properties already cover most use cases.
Maybe something like:
The text was updated successfully, but these errors were encountered: