UNPKG

preact-reconciler

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