-
Notifications
You must be signed in to change notification settings - Fork 48
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
Cannot set data-* attribute on VirtualDOM. #28
Comments
For anyone who may facing the same issue, I found an easy workaround by assign data-* as a properties.attributes object after initialise a hx. let element = hx`<a class="next" href="#">Next</a>`;
element.properties.attributes = {
"data-href": pagination.links.next
}; |
Interesting... in #16 a test was added with data-* attributes, but I think the only reason this test is passing is because toString in min-document includes stray data-* attributes in the output... when returned as a dom node by a browser, (at least in Chrome, encountered this in an electron app), data attributes are missing. There appears to be special handling for items in To fix this, when the tree is being populated with attributes: 1, 2 and 3; it needs to check if this is a data-* attribute and if so add it it to |
Thanks @tswaters for looking at this! I've found another issue that seems related to this issue when trying to assign a "style" attribute like: hx`<div class="box" style="background-color: red"></div>` This working fine in most browser except for MS Edge and Safari (didn't test on IE11 yet). And stated in the doc: https://github.com/Matt-Esch/virtual-dom/blob/master/docs/vnode.md#propertiesstyle-vs-propertiesattributesstyle
So, to workaround this, I have to do something like: const styleObj = {
backgroundColor: "red"
};
hx`<div class="box" style=${styleObj}>`; |
This is an issue with Maybe we could really put this behind a return html`<div class="Uppy UppyTheme--default UppyDashboard ${isTouchDevice ? 'Uppy--isTouchDevice' : ''}"
aria-hidden="${modal.isHidden}"
aria-label="Uppy Dialog Window (Press escape to close)"
role="dialog">
<div class="UppyDashboard-inner" tabindex="0">
...
</div>
</div> All attributes — |
- enabled by passing {vdom: true} flag to the hyperx contructor options - fixes data-*, aria-* and style as a string. vdom expects these to be under an 'attributes' property under props and will gladly ignore them otherwise fixes choojs#28
- enabled by passing {vdom: true} flag to the hyperx contructor options - fixes data-*, aria-* and style as a string. vdom expects these to be under an 'attributes' property under props and will gladly ignore them otherwise fixes choojs#28
- enabled by passing {vdom: true} flag to the hyperx contructor options - fixes data-*, aria-* and style as a string. vdom expects these to be under an 'attributes' property under props and will gladly ignore them otherwise fixes choojs#28
- enabled by passing {vdom: true} flag to the hyperx contructor options - fixes data-*, aria-* and style as a string. vdom expects these to be under an 'attributes' property under props and will gladly ignore them otherwise fixes choojs#28
- enabled by passing {vdom: true} flag to the hyperx contructor options - fixes data-*, aria-* and style as a string. vdom expects these to be under an 'attributes' property under props and will gladly ignore them otherwise fixes choojs#28
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, 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. |
Hi,
I try to set data-* attribute to element with no luck on virtual-dom
For example:
This working:
But this is not:
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.
The text was updated successfully, but these errors were encountered: