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