I have a web component that should accept an arbitrary element to wrap its content in. Although I can see in Chrome Dev Tools that the slots are properly assigned, nothing appears in the DOM. Has anybody seen this issue before?
Definition
class ExampleParent extends HTMLElement {
constructor() {
super();
const shadowRoot = this.attachShadow({ mode: 'open' });
shadowRoot.innerHTML = `
<slot name="as">
<slot name="prefix"></slot>
<slot></slot>
</slot>
`;
}
}
customElements.define('example-parent', ExampleParent);
Invocation
<example-parent
style="
min-width: 100px;
height: 40px;
border: 1px solid red;
display: inline-block;
"
>
<button slot="as"></button>
<div slot="prefix">Prefix slot</div>
Default
</example-parent>
Actual result
Expected result
Source code
https://stackblitz.com/edit/nested-slots-ahtfyf?file=index.html