For example, I want to be able to write this in HTML:
<my-container>
Some text.
</my-container>
The JS:
class MyContainer extends HTMLElement {
constructor() {
super()
const shadow = this.attachShadow({mode: 'open'})
const p = document.createElement('p')
shadow.appendChild(p)
}
}
customElements.define('my-container', MyContainer)
What I end up with (though not unexpected):
<my-container>
<p></p>
Some text.
</my-container>
What I want:
<my-container>
<p>Some text.</p>
</my-container>