Closed jarmo closed 8 years ago
Anything that needs to set using setAttribute
(i.e. not a valid DOM property) must be included in attributes
(see #405 among others)
Is this the specification of hyperscript?
I'm using dom2hscript to create hyperscript from DOM elements and it seems that it does not add these properties into attributes
:
var div = document.createElement("div")
div.dataset.foo = "bar"
div # <div data-foo="bar"></div>
dom2hscript.parseDOM(div) # "h('DIV',{"data-foo":"bar"},[])"
What are you considering the hyperscript spec?
Okay, let me rephrase my question since I do not know too much about hyperscript - does virtual-dom expect hyperscript to define attributes with dashes like that or does it have to be like that in general? In other words - is there a bug in dom2hscript rather than in virtual-dom?
Hyperscript is more of a loose standard than an explicit spec. Most attributes should be camel cased because they are real DOM attributes that the browser will handle, e.g. scrollTop
. Anything that's not a native DOM attribute should be set with attributes
.
Thank you for clarifying. I've opened a separate issue under dom2hscript library referencing this issue so we can close this one.
patch
loses HTML 5 data attributes, because it does apply properties to node like this:Correct (?) way would be to use
node.setAttribute(propName, propValue)
instead althoughclassName
is a special case.Or am I missing something?