forked from vanjs-org/van
-
Notifications
You must be signed in to change notification settings - Fork 0
/
van-0.10.0.nomodule.min.js
1 lines (1 loc) · 1.25 KB
/
van-0.10.0.nomodule.min.js
1
{let t,e,n,s,r,o,i,a,l,u,c,d;e=document,n=Object,s=null,o=r={},i=class{constructor(t){this.t=t,this.o=[],this.i=[]}get val(){return this.t}set val(e){let n=this;e!==n.t&&(n.l?e===n.l&&(n.l=s,t.delete(n)):((e=>{t=(t??(setTimeout(c),new Set)).add(e)})(n),n.l=n.t),n.t=e,n.i.forEach((t=>t())))}},a=t=>new i(t),l=(t,...n)=>n.flat(1/0).forEach((n=>{return t.appendChild((s=n)instanceof Node?s:s instanceof i?d(s,(t=>e.createTextNode(t))):e.createTextNode(s));var s})),u=new Proxy(((t,...s)=>{let[r,...o]=s[0]?.constructor===n?s:[{},...s],a=e.createElement(t);return n.entries(r).forEach((([t,e])=>{t.startsWith("on")?a[t]=e:e instanceof i?d(e,(e=>(a[t]=e,a))):a.setAttribute(t,e)})),l(a,...o),a}),{get:(t,e)=>t.bind(s,e)}),c=()=>{let e=[...t];t=s,new Set(e.flatMap((t=>t.o=t.o.filter((t=>t.u.isConnected))))).forEach((t=>{let{u:e,h:n,m:s}=t,o=s(...n.map((t=>t.t)),e,...n.map((t=>t.l)));o!==e&&(o!==r?e.replaceWith(o):e.remove(),t.u=o)})),e.forEach((t=>t.l=s))},d=(...t)=>{let e=t.slice(0,-1),n=t[t.length-1],s=n(...e.map((t=>t.t)));if(s===r)return[];if(s instanceof Node){let t={h:e,u:s,m:n};return e.forEach((e=>e.o.push(t))),s}let o=a(s),i=()=>o.val=n(...e.map((t=>t.t)),o.t,...e.map((t=>t.l)));return e.forEach((t=>t.i.push(i))),o},window.van={add:l,tags:u,state:a,bind:d,empty:o};}