WebReflection / hyperHTML

A Fast & Light Virtual DOM Alternative
ISC License
3.07k stars 113 forks source link

Creating options for select element with wire method generates comment nodes. #371

Closed dbauszus-glx closed 5 years ago

dbauszus-glx commented 5 years ago

I create an option tag element and pass a string to the innerHTML like so:

wire()`<option value="F00">${'FOO'}`;

This creates a second child node in the option element.

{
  data: "-0.765193%",
  nodeName: "#comment",
​​  nodeType: 8,
​​  nodeValue: "-0.765193%",
  previousSibling: #text,
  textContent: "-0.765193%",
}

In order to generate the option tag with the expected single #text node it is necessary to create the option with wire and then assign the string to the textcontent like so:

wire()`<option value="F00" textContent=${'FOO'}>`;

Is this the expected behavior?

pinguxx commented 5 years ago

the comment is required for hyperhtml to update things later, but https://codepen.io/pinguxx/pen/ydzxOo

seems to be working ok

WebReflection commented 5 years ago

Just ignore comments, which are completely irrelevant but strictly necessary.

Also explained in here https://gist.github.com/WebReflection/d3aad260ac5007344a0731e797c8b1a4