html-to-vdom icon indicating copy to clipboard operation
html-to-vdom copied to clipboard

Inconsistent attribute handling

Open ivan-kleshnin opened this issue 9 years ago • 2 comments

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' },
  ...
}

ivan-kleshnin avatar Dec 15 '15 12:12 ivan-kleshnin

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 avatar Jan 16 '16 14:01 TimBeyer

@TimBeyer FYI, this seems to give problems with tools such as vtree-select.

remko avatar Oct 08 '16 13:10 remko