UNPKG

preact-reconciler

Version:
2 lines (1 loc) 1.85 kB
import{options as B,render as P}from"preact";const S=0,E=4;class x extends HTMLElement{setAttribute(n,t){var o,i,l,b,m;this[n]=t;const e=this.a,u=e==null?void 0:e.f;if(u){const C=e.e,r=(o=this.c)!=null?o:this.c=C.c,d=C.d,s=e.props;if(s[n]=t,e.b){e.sibling=(l=(i=this.nextSibling)==null?void 0:i.a)!=null?l:null,e.flags=(b=this.nextSibling)!=null&&b.nextSibling?E:S;const a=e.g;a[n]=t;const p=e.b;if(r.prepareUpdate){const c=r.prepareUpdate(p,u,a,s,d,null);c&&r.commitUpdate(p,c,u,a,s,e)}else(m=r.commitUpdate)==null||m.call(r,p,u,a,s,e)}else{this.ownerSVGElement=null,delete s.a,e.g={...s};const a=e.b=r.createInstance(u,s,d,null,e);let p=e.ref;Object.defineProperty(e,"ref",{get(){return p},set(c){p=I=>{var _;const v=I!=null,g=v?r.getPublicInstance(a):null;c&&"current"in c?c.current=g:v?e.refCleanup=c==null?void 0:c(g):(_=e.refCleanup)==null||_.call(e)}}}),e.ref=p,r.finalizeInitialChildren(a,u,s,d,null)&&r.commitMount(a,u,s,e)}}}appendChild(n){const t=n;return this.a?this.c.appendChild(this.a.b,t.a.b):this.c.appendChildToContainer(this.d,t.a.b),super.appendChild(n)}insertBefore(n,t){if(t===null)return this.appendChild(n);const o=n,i=t;return this.a?this.c.insertBefore(this.a.b,o.a.b,i.a.b):this.c.insertInContainerBefore(this.d,o.a.b,i.a.b),super.insertBefore(n,t)}removeChild(n){const t=n;return this.a?this.c.removeChild(this.a.b,t.a.b):this.c.removeChildFromContainer(this.d,t.a.b),super.removeChild(n)}}const y=B;let h;const T=f=>{if(!h){customElements.define(h="preact-reconciler",x);const n=y.__b;y.__b=t=>{var o;const i=t;if(typeof i.type=="string"&&!i.e){let l=i.__;for(;l!=null&&l.__;)l=l.__;i.e=l==null?void 0:l.__c.__P,(o=i.e)!=null&&o.c&&(i.f=i.type,i.type=h,i.props.a=i)}n==null||n(t)}}return{createContainer(n){const t=new x;return t.d=n,t.c=f,t},updateContainer:P,createPortal(){},injectIntoDevTools(){}}};export{T as default};