Consider this code:
//js
class FooBar extends HTMLElement {
constructor(){
super();
}
}
customElements.define('foo-bar', FooBar);
<!-- html -->
<foo-bar>
<h1>Test</h1>
</foo-bar>
This will show »Test« within the browser.
If the constructor is changed to:
constructor () {
super();
this.shadow = this.attachShadow({ mode: 'open' })
}
The »Test« disappears, since there is a shadow root now.
If the constructor is furthermore changed to
constructor () {
super();
this.shadow = this.attachShadow({ mode: 'open' });
this.shadow.appendChild(document.createElement('slot'));
}
The »Test« appears again, since there is now a default slot for all child Nodes of <foo-bar>
But what happens to the child nodes if there is no <slot /> within the shadow root. They still appear within this.children and its style.display property remains "". So they are within the dom, but not rendered, even thou thr css tells the opposite? What exactly happens here?
