UNPKG

preact-reconciler

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