Files
webcomponentsjs/webcomponents-hi-ce-es5.js
Daniel Freedman d7b5141a1a Make sure ce-es5 bundle fires WebComponentsReady
Don't rely on HTMLImports

Also, minify bundles with babili
2017-03-06 14:08:54 -08:00

17 lines
8.9 KiB
JavaScript

(function () {
'use strict';
(()=>{'use strict';if(!window.customElements)return;const a=window.HTMLElement,b=window.customElements.define,c=window.customElements.get,d=new Map,e=new Map;let f=!1,g=!1;window.HTMLElement=function(){if(!f){const h=d.get(this.constructor),i=c.call(window.customElements,h);g=!0;const j=new i;return j}f=!1;},window.HTMLElement.prototype=a.prototype,window.customElements.define=(h,i)=>{const j=i.prototype,k=class extends a{constructor(){super(),Object.setPrototypeOf(this,j),g||(f=!0,i.call(this)),g=!1;}},l=k.prototype;k.observedAttributes=i.observedAttributes,l.connectedCallback=j.connectedCallback,l.disconnectedCallback=j.disconnectedCallback,l.attributeChangedCallback=j.attributeChangedCallback,l.adoptedCallback=j.adoptedCallback,d.set(i,h),e.set(h,i),b.call(window.customElements,h,k);},window.customElements.get=(h)=>e.get(h);})();
((a)=>{const b=!!('import'in document.createElement('link'));let c=null;!1=='currentScript'in document&&Object.defineProperty(document,'currentScript',{get(){return c||('complete'===document.readyState?null:document.scripts[document.scripts.length-1])},configurable:!0});const d=/(^\/)|(^#)|(^[\w-\d]*:)/,f=/(url\()([^)]*)(\))/g,g=/(@import[\s]+(?!url\())([^;]*)(;)/g,h=/(<link[^>]*)(rel=['|"]?stylesheet['|"]?[^>]*>)/g,k={fixUrls(J,K){if(J.href&&J.setAttribute('href',k.replaceAttrUrl(J.getAttribute('href'),K)),J.src&&J.setAttribute('src',k.replaceAttrUrl(J.getAttribute('src'),K)),'style'===J.localName){const L=k.replaceUrls(J.textContent,K,f);J.textContent=k.replaceUrls(L,K,g);}},replaceUrls(J,K,L){return J.replace(L,(M,N,O,P)=>{let Q=O.replace(/["']/g,'');return K&&(Q=k.resolveUrl(Q,K)),N+'\''+Q+'\''+P})},replaceAttrUrl(J,K){return J&&d.test(J)?J:k.resolveUrl(J,K)},resolveUrl(J,K){if(void 0===k.__workingURL){k.__workingURL=!1;try{const M=new URL('b','http://a');M.pathname='c%20d',k.__workingURL='http://a/c%20d'===M.href;}catch(M){}}if(k.__workingURL)return new URL(J,K).href;let L=k.__tempDoc;return L||(L=document.implementation.createHTMLDocument('temp'),k.__tempDoc=L,L.__base=L.createElement('base'),L.head.appendChild(L.__base),L.__anchor=L.createElement('a')),L.__base.href=K,L.__anchor.href=J,L.__anchor.href||J}},o={async:!0,load(J,K,L){if(!J)L('error: href must be specified');else if(J.match(/^data:/)){const M=J.split(','),N=M[0];let O=M[1];O=-1<N.indexOf(';base64')?atob(O):decodeURIComponent(O),K(O);}else{const M=new XMLHttpRequest;M.open('GET',J,o.async),M.onload=()=>{let N=M.getResponseHeader('Location');if(N&&0===N.indexOf('/')){const P=location.origin||location.protocol+'//'+location.host;N=P+N;}const O=M.response||M.responseText;304===M.status||0===M.status||200<=M.status&&300>M.status?K(O,N):L(O);},M.send();}}},p=/Trident/.test(navigator.userAgent)||/Edge\/\d./i.test(navigator.userAgent),q='link[rel=import]',t='import-disable',v=`link[rel=stylesheet][href][type=${t}]`,w=`${q}, ${v},
style:not([type]), link[rel=stylesheet][href]:not([type]),
script:not([type]), script[type="application/javascript"],
script[type="text/javascript"]`,x='import-dependency',y=`${q}:not(${x})`,z=`script[${x}]`,A=`style[${x}],
link[rel=stylesheet][${x}]`;const C=(J)=>{return J.nodeType===Node.ELEMENT_NODE&&'link'===J.localName&&'import'===J.rel},D=(J,K)=>{if(J.__loaded)K&&K();else if('script'===J.localName&&!J.src)J.__loaded=!0,K&&K();else{const L=(M)=>{J.removeEventListener(M.type,L),J.__loaded=!0,K&&K();};J.addEventListener('load',L),p&&'style'===J.localName||J.addEventListener('error',L);}},E=(J)=>{F(()=>G(()=>J&&J()));},F=(J)=>{if('loading'!==document.readyState)J();else{const K=()=>{'loading'!==document.readyState&&(document.removeEventListener('readystatechange',K),J());};document.addEventListener('readystatechange',K);}},G=(J)=>{let K=document.querySelectorAll(y),L=K.length;if(!L)return void J();for(let O,M=0,N=K.length;M<N&&(O=K[M]);M++)D(O,()=>{0==--L&&J();});},H=(J)=>{if(b)return J.ownerDocument===document?null:J.ownerDocument;let K=J.__importDoc;if(!K&&J.parentNode){if(K=J.parentNode,'function'==typeof K.closest)K=K.closest(q);else for(;!C(K)&&(K=K.parentNode););J.__importDoc=K;}return K},I=(J,K)=>{if('function'==typeof window.CustomEvent)return new CustomEvent(J,K);const L=document.createEvent('CustomEvent');return L.initCustomEvent(J,!!K.bubbles,!!K.cancelable,K.detail),L};if(b){const J=document.querySelectorAll(q);for(let N,L=0,M=J.length;L<M&&(N=J[L]);L++)N.import&&'loading'===N.import.readyState||(N.__loaded=!0);const K=(L)=>{const M=L.target;C(M)&&(M.__loaded=!0);};document.addEventListener('load',K,!0),document.addEventListener('error',K,!0);}else new class{constructor(){this.documents={},this.inflight=0,this.dynamicImportsMO=new MutationObserver((J)=>this.handleMutations(J)),F(()=>{this.dynamicImportsMO.observe(document.head,{childList:!0,subtree:!0}),this.loadImports(document);});}loadImports(J){const K=J.querySelectorAll(q);for(let L=0,M=K.length;L<M;L++)this.loadImport(K[L]);}loadImport(J){const K=J.href;if(void 0!==this.documents[K]){const L=this.documents[K];return void(L&&L.__loaded&&(J.import=L,this.fireEventIfNeeded(J)))}this.inflight++,this.documents[K]='pending',o.load(K,(L,M)=>{const N=this.makeDocument(L,M||K);this.documents[K]=N,this.inflight--,this.loadImports(N),this.processImportsIfLoadingDone();},()=>{this.documents[K]=null,this.inflight--,this.processImportsIfLoadingDone();});}makeDocument(J,K){if(!J)return document.createDocumentFragment();p&&(J=J.replace(h,(Q,R,S)=>{return-1===Q.indexOf('type=')?`${R} type=${t} ${S}`:Q}));let L;const M=document.createElement('template');if(M.innerHTML=J,M.content)L=M.content;else for(L=document.createDocumentFragment();M.firstChild;)L.appendChild(M.firstChild);const N=L.querySelector('base');N&&(K=k.replaceAttrUrl(N.getAttribute('href'),K),N.removeAttribute('href'));const O=L.querySelectorAll(w);let P=0;for(let S,Q=0,R=O.length;Q<R&&(S=O[Q]);Q++)if(D(S),k.fixUrls(S,K),S.setAttribute(x,''),'script'===S.localName&&!S.src&&S.textContent){const T=P?`-${P}`:'',U=S.textContent+`\n//# sourceURL=${K}${T}.js\n`;S.setAttribute('src','data:text/javascript;charset=utf-8,'+encodeURIComponent(U)),S.textContent='',P++;}return L}processImportsIfLoadingDone(){if(this.inflight)return;this.dynamicImportsMO.disconnect(),this.flatten(document);let J=!1,K=!1;const L=()=>{K&&J&&(this.dynamicImportsMO.observe(document.head,{childList:!0,subtree:!0}),this.fireEvents());};this.waitForStyles(()=>{K=!0,L();}),this.runScripts(()=>{J=!0,L();});}flatten(J){const K=J.querySelectorAll(q);for(let N,L=0,M=K.length;L<M&&(N=K[L]);L++){const O=this.documents[N.href];N.import=O,O&&O.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&(this.documents[N.href]=N,N.readyState='loading',N.import=N,Object.defineProperty(N,'baseURI',{get:()=>N.href,configurable:!0,enumerable:!0}),this.flatten(O),N.appendChild(O));}}runScripts(J){const K=document.querySelectorAll(z),L=K.length,M=(N)=>{if(N<L){const O=K[N],P=document.createElement('script');O.removeAttribute(x);for(let Q=0,R=O.attributes.length;Q<R;Q++)P.setAttribute(O.attributes[Q].name,O.attributes[Q].value);c=P,O.parentNode.replaceChild(P,O),D(P,()=>{c=null,M(N+1);});}else J();};M(0);}waitForStyles(J){const K=document.querySelectorAll(A);let L=K.length;if(!L)return void J();const M=p&&!!document.querySelector(v);for(let P,N=0,O=K.length;N<O&&(P=K[N]);N++)if(D(P,()=>{P.removeAttribute(x),0==--L&&J();}),M&&P.parentNode!==document.head){const Q=document.createElement(P.localName);Q.__appliedElement=P,Q.setAttribute('type','import-placeholder'),P.parentNode.insertBefore(Q,P.nextSibling);let R=H(P);for(;R&&H(R);)R=H(R);R.parentNode!==document.head&&(R=null),document.head.insertBefore(P,R),P.removeAttribute('type');}}fireEvents(){const J=document.querySelectorAll(q);for(let L,K=J.length-1;0<=K&&(L=J[K]);K--)this.fireEventIfNeeded(L);}fireEventIfNeeded(J){if(!J.__loaded){J.__loaded=!0,J.import&&(J.import.readyState='complete');const K=J.import?'load':'error';J.dispatchEvent(I(K,{bubbles:!1,cancelable:!1,detail:void 0}));}}handleMutations(J){for(let K=0;K<J.length;K++){const L=J[K];if(L.addedNodes)for(let M=0;M<L.addedNodes.length;M++){const N=L.addedNodes[M];N&&N.nodeType===Node.ELEMENT_NODE&&(C(N)?this.loadImport(N):this.loadImports(N));}}}};E(()=>document.dispatchEvent(I('HTMLImportsLoaded',{cancelable:!0,bubbles:!0,detail:void 0}))),a.useNative=b,a.whenReady=E,a.importForElement=H;})(window.HTMLImports=window.HTMLImports||{});
(function(){'use strict';var a=window.customElements,b=window.HTMLImports;if(a&&a.polyfillWrapFlushCallback){var c,d=function(){if(c){var g=c;return c=null,g(),!0}},e=b.whenReady;a.polyfillWrapFlushCallback(function(f){c=f,e(d);}),b.whenReady=function(f){e(function(){d()?b.whenReady(f):f();});};}b.whenReady(function(){requestAnimationFrame(function(){window.dispatchEvent(new CustomEvent('WebComponentsReady'));});});})();
(function(){'use strict';var a=document.createElement('style');a.textContent='body {transition: opacity ease-in 0.2s; } \\nbody[unresolved] {opacity: 0; display: block; overflow: hidden; position: relative; } \\n';var b=document.querySelector('head');b.insertBefore(a,b.firstChild);})();
}());