I want to make a web component from a <select> Element. I'm trying to get the <option> tags supplied by the user to appear in the Shadow DOM.
My component:
let tmpl = document.createElement('template');
tmpl.innerHTML = `
<select placeholder="text">
<slot name="option"></slot>
</select>
`;
class SelectBox extends HTMLElement {
constructor() {
super();
if (!this.shadowRoot) {
this.root = this.attachShadow({mode: 'open'});
this.root.appendChild(tmpl.content.cloneNode(true));
}
}
}
customElements.define('select-box', SelectBox);
HTML:
<select-box>
<option slot="option" value="text">text</option>
</select-box>
What's being rendered is an empty select box. I can see in the console that the element is empty

Which leads me to believe I haven't grasped the process of inserting user elements into the shadow DOM.