html-to-vdom
html-to-vdom copied to clipboard
Inconsistent attribute handling
virtual-dom attribute names differ from basic HTML in two cases:
-
for -> htmlFor
-
class -> className
html-to-vdom does not behave consistent about the subj.
It automatically renames for
to htmlFor
but does not rename class
to className
.
import VNode from "virtual-dom/vnode/vnode";
import VText from "virtual-dom/vnode/vtext";
import HtmlToVdom from "html-to-vdom";
let convertHTML = HtmlToVdom({
VNode: VNode,
VText: VText
});
let html = `<p for="email" class="xxx">test</p>`;
convertHTML(html);
// actual result
VirtualNode {
properties: { attributes: { class: 'xxx' }, htmlFor: 'email' },
...
}
// expected result
VirtualNode {
properties: { attributes: { className: 'xxx' }, htmlFor: 'email' },
...
}
Hey @ivan-kleshnin,
I haven't looked at this for a while, but I believe this is the correct behavior for the highest browser compatiblity. The difference is between attributes
and properties
. The correct property
is className
but the correct cross-browser attribute
is class
.
Has this actually caused buggy behavior for you? If so I'll try to come up with something.
@TimBeyer FYI, this seems to give problems with tools such as vtree-select
.