Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 2592

Rescript vanilla web components (classes)

$
0
0

Just tried out some stuff with web components a few months ago:

let define: options => unit = %ffi(`
function(options) {
  const clazz = class extends HTMLElement {
    constructor() {
      super()
    }

    connectedCallback() {
      if (this.attached) {
        return;
      }

      this.attached = true;

      this.shadowRoot.appendChild(options.render());
    }

  }

  customElements.define(options.name, clazz)
}
`)

Viewing all articles
Browse latest Browse all 2592

Trending Articles