choojs / hyperx

🏷 - tagged template string virtual dom builder
BSD 2-Clause "Simplified" License
1.01k stars 48 forks source link

Is it possible to add some kind of opt-in for hyperscript-attribute-to-property? #48

Closed jorgebucaran closed 7 years ago

jorgebucaran commented 7 years ago

Currently:

hx`<div class="hi">Hello</div>`

Produces (using a hyperscript-like function):

{
  children: ["Hello"],
  data: {
    className: "hi"
  },
  tag: "div"
}

This requires your vdom engine to check if data has a className prop and use class instead, otherwise you end up with HTML elements that have both class and className attributes.

On the other hand, JSX correctly yields:

{
  children: ["Hello"],
  data: {
    class: "hi"
  },
  tag: "div"
}

Related: