Cannot set data-* attribute on VirtualDOM.
See original GitHub issueHi,
I try to set data-* attribute to element with no luck on virtual-dom
For example: This working:
hx`<a href="${pagination.links.next}">Next</a>`
But this is not:
hx`<a href="#" data-href="${pagination.links.next}">Next</a>`
I’ve googled and found this https://github.com/Matt-Esch/virtual-dom/blob/master/docs/vnode.md#custom-attributes-data- which maybe related to my issue.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:5
Top Results From Across the Web
javascript - JQuery, cannot assign data attribute after creation
I'm trying to add some data attributes to a list element after creation. var el = document.createElement('li'); el.
Read more >Developers - Cannot set data-* attribute on VirtualDOM. -
Hi,. I try to set data-* attribute to element with no luck on virtual-dom. For example: This working: hx`<a href="${pagination.links.next}">Next</a>`.
Read more >Adventures in the Virtual DOM — Part 4: Rendering Attributes
This function is going to expand as we add more attribute types. We're going to add handling here for events, classes, styles, data...
Read more >In JavaScript data binding, why use the data attribute instead ...
Well, first you can't easily extend DOM objects. The DOM has control of ... The data attribute exists for HTML/JS interchange. ... Could...
Read more >How do I add data attributes to a script using the HTML builder
The purpose of this topic is to allow Discourse developers to understand how the new code works. What's a Virtual DOM? A Virtual...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry for all the noise there, pushed up some force commits after I noticed some errors…
The PR has been adjusted to use a flag,
{vdom: true}
- this will fix data-, aria- and style being passed as a string. I noticed that tabindex and role both seemed to work without any explicit modifications, so maybe that was a bug upstream that is now fixed.That reminds me - on the note of upstream bugs. Note that the tests relating to style as a string won’t pass unless min-document v2.18.1 is present, due to this bug. This matches the version in this package.json so it should be fine.
This is an issue with
aria
(and thus accessibility) too, I’m currently struggling with it: since I have a nested tree of elements that I want to put attributes likearia-hidden
on. Works fine withbel
, but notvirtual-dom
.Maybe we could really put this behind a
supportVDomAttributes
flag, as suggested in https://github.com/substack/hyperx/pull/29, or something?All attributes —
aria
,role
,tabindex
— except forclass
are missing from the resulting DOM.