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)
}
`)