@typedarray/custom-elements
v0.1.0
Published
custom-elements shim
Downloads
4
Readme
@typedarray/custom-elements
custom-elements shim
class MyCustomElement extends HTMLElement {}
const div = new HTMLDivElement();
const slot = new HTMLSlotElement();
...
Usage
import '@typedarray/custom-elements';
class MyCustomElement extends HTMLElement {
constructor() {
super();
const shadowRoot = this.attachShadow({ mode: 'open' });
const slot = new HTMLSlotElement();
shadowRoot.appendChild(slot);
}
}
customElements.define('my-custom-element', MyCustomElement);
<my-custom-element>
<span>slot content</span>
</my-custom-element>
const element = new MyCustomElement();
element.appendChild(document.createTextNode('slot content'));
document.body.appendChild(element);