0.1.0 • Published 3 years ago

@typedarray/custom-elements v0.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

@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);