I have this JS and HTML content:
const parent = document.querySelector('#parent');
const choices = parent.dataset.choices.split(",")
const childTplt = document.querySelector('#children');
for (c of choices) {
let child = childTplt.content.cloneNode(true);
child.appendChild(document.createTextNode(c));
parent.appendChild(child);
}
<ul id="parent" data-choices="one,two,three">
</ul>
<template id="children">
<li> </li>
</template>
and end up with this on my page:
<ul id="parent" data-choices="one,two,three">
<li> </li>
one
<li> </li>
two
<li> </li>
three</ul>
Why is that text content ends up as sibling of <li> and not as an actual children (inside of <li></li> ?
thanks for your input!