-
Notifications
You must be signed in to change notification settings - Fork 1
/
min.js
2 lines (2 loc) · 1017 Bytes
/
min.js
1
2
/*! (c) Andrea Giammarchi - ISC */
const HTMLParsedElement=(()=>{const e="DOMContentLoaded",t=new WeakMap,n=[],a=e=>{do{if(e.nextSibling)return!0}while(e=e.parentNode);return!1},r=()=>{n.splice(0).forEach(e=>{!0!==t.get(e[0])&&(t.set(e[0],!0),e[0][e[1]]())})};document.addEventListener(e,r);class s extends HTMLElement{static withParsedCallback(s,i="parsed"){const{prototype:c}=s,{connectedCallback:o}=c,l=i+"Callback",d=(t,n,a,r)=>{n.disconnect(),a.removeEventListener(e,r),u(t)},u=e=>{n.length||requestAnimationFrame(r),n.push([e,l])};return Object.defineProperties(c,{connectedCallback:{configurable:!0,writable:!0,value(){if(o&&o.apply(this,arguments),l in this&&!t.has(this)){const n=this,{ownerDocument:r}=n;if(t.set(n,!1),"complete"===r.readyState||a(n))u(n);else{const t=()=>d(n,s,r,t);r.addEventListener(e,t);const s=new MutationObserver(()=>{a(n)&&d(n,s,r,t)});s.observe(n.parentNode,{childList:!0,subtree:!0})}}}},[i]:{configurable:!0,get(){return!0===t.get(this)}}}),s}}return s.withParsedCallback(s)})();