vanjs-element
Version:
Web components with VanJS
1 lines • 491 B
JavaScript
import t from"vanjs-core";function e(e,s,i={mode:"open"}){window.customElements.define(e,class extends HTMLElement{constructor(){super(),this.a=[]}setAttribute(t,e){super.setAttribute(t,e),this.a[t]&&(this.a[t].val=e)}connectedCallback(){let e;t.add(i?this.attachShadow(i):this,s({attr:(e,s)=>this.a[e]??=t.state(this.getAttribute(e)??s),mount:t=>{let s=e;e=()=>{let e=s?.(),i=t();return()=>{e?.(),i?.()}}},$this:this})),this.d=e?.()}disconnectedCallback(){this.d?.()}})}export{e as define};