forked from webcomponents/custom-elements
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom-elements.min.js
More file actions
40 lines (39 loc) · 13.8 KB
/
Copy pathcustom-elements.min.js
File metadata and controls
40 lines (39 loc) · 13.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
(function(){
/*
Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
'use strict';var aa=new Set("annotation-xml color-profile font-face font-face-src font-face-uri font-face-format font-face-name missing-glyph".split(" ")),ba=/^[a-z][.0-9_a-z]*-[\-.0-9_a-z]*$/;function k(b){var a=aa.has(b);b=ba.test(b);return!a&&b}
function m(b){var a=b.isConnected;if(void 0!==a)return a;for(;b&&!(b.__CE_isImportDocument||b instanceof Document);)b=b.parentNode||(window.ShadowRoot&&b instanceof ShadowRoot?b.host:void 0);return!(!b||!(b.__CE_isImportDocument||b instanceof Document))}function q(b,a){for(;a&&a!==b&&!a.nextSibling;)a=a.parentNode;return a&&a!==b?a.nextSibling:null}
function t(b,a,c){c=void 0===c?new Set:c;for(var d=b;d;){if(d.nodeType===Node.ELEMENT_NODE){var e=d;a(e);var f=e.localName;if("link"===f&&"import"===e.getAttribute("rel")){d=e.import;if(d instanceof Node&&!c.has(d))for(c.add(d),d=d.firstChild;d;d=d.nextSibling)t(d,a,c);d=q(b,e);continue}else if("template"===f){d=q(b,e);continue}if(e=e.__CE_shadowRoot)for(e=e.firstChild;e;e=e.nextSibling)t(e,a,c)}d=d.firstChild?d.firstChild:q(b,d)}}function v(b,a,c){b[a]=c};function w(){this.a=new Map;this.f=new Map;this.c=[];this.g=0;this.b=!1}function ca(b,a,c){b.a.set(a,c);b.f.set(c.constructorFunction,c)}function da(b,a){b.b=!0;b.c[b.g++]=a}function y(b,a){b.b&&t(a,function(a){return z(b,a)})}function z(b,a){if(b.b&&!a.__CE_patched){a.__CE_patched=!0;for(var c=0,d=b.c.length;c<d;c++)b.c[c](a)}}function A(b,a){var c=[],d=0;t(a,function(a){return c[d++]=a});for(a=0;a<d;a++){var e=c[a];1===e.__CE_state?b.connectedCallback(e):B(b,e)}}
function C(b,a){var c=[],d=0;t(a,function(a){return c[d++]=a});for(a=0;a<d;a++){var e=c[a];1===e.__CE_state&&b.disconnectedCallback(e)}}
function D(b,a,c){c=void 0===c?{}:c;var d=c.u||new Set,e=c.i||function(a){return B(b,a)},f=[],g=0;t(a,function(a){if("link"===a.localName&&"import"===a.getAttribute("rel")){var c=a.import;c instanceof Node&&(c.__CE_isImportDocument=!0,c.__CE_hasRegistry=!0);c&&"complete"===c.readyState?c.__CE_documentLoadHandled=!0:a.addEventListener("load",function(){var c=a.import;if(!c.__CE_documentLoadHandled){c.__CE_documentLoadHandled=!0;var f=new Set(d);f.delete(c);D(b,c,{u:f,i:e})}})}else f[g++]=a},d);if(b.b)for(a=
0,c=f.length;a<c;a++)z(b,f[a]);a=0;for(c=f.length;a<c;a++)e(f[a])}
function B(b,a){if(void 0===a.__CE_state){var c=a.ownerDocument;if(c.defaultView||c.__CE_isImportDocument&&c.__CE_hasRegistry)if(c=b.a.get(a.localName)){c.constructionStack.push(a);var d=c.constructorFunction;try{try{if(new d!==a)throw Error("The custom element constructor did not produce the element being upgraded.");}finally{c.constructionStack.pop()}}catch(e){throw a.__CE_state=2,e;}a.__CE_state=1;a.__CE_definition=c;m(a)&&b.connectedCallback(a)}}}
w.prototype.connectedCallback=function(b){var a=b.__CE_definition;a.connectedCallback&&a.connectedCallback.call(b)};w.prototype.disconnectedCallback=function(b){var a=b.__CE_definition;a.disconnectedCallback&&a.disconnectedCallback.call(b)};w.prototype.attributeChangedCallback=function(b,a,c,d,e){var f=b.__CE_definition;f.attributeChangedCallback&&-1<f.observedAttributes.indexOf(a)&&f.attributeChangedCallback.call(b,a,c,d,e)};function E(b){var a=document;this.c=b;this.a=a;this.b=void 0;D(this.c,this.a);"loading"===this.a.readyState&&(this.b=new MutationObserver(this.f.bind(this)),this.b.observe(this.a,{childList:!0,subtree:!0}))}function F(b){b.b&&b.b.disconnect()}E.prototype.f=function(b){var a=this.a.readyState;"interactive"!==a&&"complete"!==a||F(this);a=0;for(var c=b.length;a<c;a++)for(var d=b[a].addedNodes,e=0,f=d.length;e<f;e++)D(this.c,d[e])};function ea(){var b=this;this.b=this.a=void 0;this.c=new Promise(function(a){b.b=a;b.a&&a(b.a)})}function G(b){if(b.a)throw Error("Already resolved.");b.a=void 0;b.b&&b.b(void 0)};function H(b){this.c=!1;this.a=b;this.j=new Map;this.f=function(a){return a()};this.b=!1;this.g=[];this.o=new E(b)}
H.prototype.l=function(b,a){var c=this;if(!(a instanceof Function))throw new TypeError("Custom element constructors must be functions.");if(!k(b))throw new SyntaxError("The element name '"+b+"' is not valid.");if(this.a.a.get(b))throw Error("A custom element with name '"+b+"' has already been defined.");if(this.c)throw Error("A custom element is already being defined.");this.c=!0;try{var d=function(a){var b=e[a];if(void 0!==b&&!(b instanceof Function))throw Error("The '"+a+"' callback must be a function.");
return b},e=a.prototype;if(!(e instanceof Object))throw new TypeError("The custom element constructor's prototype is not an object.");var f=d("connectedCallback");var g=d("disconnectedCallback");var h=d("adoptedCallback");var n=d("attributeChangedCallback");var p=a.observedAttributes||[]}catch(x){return}finally{this.c=!1}a={localName:b,constructorFunction:a,connectedCallback:f,disconnectedCallback:g,adoptedCallback:h,attributeChangedCallback:n,observedAttributes:p,constructionStack:[]};ca(this.a,
b,a);this.g.push(a);this.b||(this.b=!0,this.f(function(){return fa(c)}))};H.prototype.i=function(b){D(this.a,b)};
function fa(b){if(!1!==b.b){b.b=!1;for(var a=b.g,c=[],d=0,e=new Map,f=0,g=a.length;f<g;f++)e.set(a[f].localName,[]);D(b.a,document,{i:function(a){if(void 0===a.__CE_state){var f=a.localName,h=e.get(f);h?h.push(a):b.a.a.get(f)&&(c[d++]=a)}}});f=0;for(g=c.length;f<g;f++)B(b.a,c[f]);for(;0<a.length;){g=a.shift();f=g.localName;g=e.get(g.localName);for(var h=0,n=g.length;h<n;h++)B(b.a,g[h]);(f=b.j.get(f))&&G(f)}}}H.prototype.get=function(b){if(b=this.a.a.get(b))return b.constructorFunction};
H.prototype.m=function(b){if(!k(b))return Promise.reject(new SyntaxError("'"+b+"' is not a valid custom element name."));var a=this.j.get(b);if(a)return a.c;a=new ea;this.j.set(b,a);this.a.a.get(b)&&!this.g.some(function(a){return a.localName===b})&&G(a);return a.c};H.prototype.s=function(b){F(this.o);var a=this.f;this.f=function(c){return b(function(){return a(c)})}};window.CustomElementRegistry=H;H.prototype.define=H.prototype.l;H.prototype.upgrade=H.prototype.i;H.prototype.get=H.prototype.get;
H.prototype.whenDefined=H.prototype.m;H.prototype.polyfillWrapFlushCallback=H.prototype.s;var I=window.Document.prototype.createElement,J=window.Document.prototype.createElementNS,ha=window.Document.prototype.importNode,ia=window.Document.prototype.prepend,ja=window.Document.prototype.append,ka=window.DocumentFragment.prototype.prepend,la=window.DocumentFragment.prototype.append,K=window.Node.prototype.cloneNode,L=window.Node.prototype.appendChild,M=window.Node.prototype.insertBefore,N=window.Node.prototype.removeChild,O=window.Node.prototype.replaceChild;
Object.getOwnPropertyDescriptor(window.Node.prototype,"textContent");
var P=window.Element.prototype.attachShadow,Q=Object.getOwnPropertyDescriptor(window.Element.prototype,"innerHTML"),R=window.Element.prototype.insertAdjacentElement,S=window.Element.prototype.insertAdjacentHTML,ma=window.Element.prototype.prepend,na=window.Element.prototype.append,T=window.Element.prototype.before,oa=window.Element.prototype.after,U=window.Element.prototype.replaceWith,V=window.Element.prototype.remove,pa=window.HTMLElement,W=Object.getOwnPropertyDescriptor(window.HTMLElement.prototype,
"innerHTML"),qa=window.HTMLElement.prototype.insertAdjacentElement,ra=window.HTMLElement.prototype.insertAdjacentHTML;var sa=new function(){};function ta(){var b=X;window.HTMLElement=function(){function a(){var a=this.constructor,d=b.f.get(a);if(!d)throw Error("The custom element being constructed was not registered with `customElements`.");var e=d.constructionStack;if(0===e.length)return e=I.call(document,d.localName),Object.setPrototypeOf(e,a.prototype),e.__CE_state=1,e.__CE_definition=d,z(b,e),e;d=e.length-1;var f=e[d];if(f===sa)throw Error("The HTMLElement constructor was either called reentrantly for this constructor or called multiple times.");
e[d]=sa;Object.setPrototypeOf(f,a.prototype);z(b,f);return f}a.prototype=pa.prototype;Object.defineProperty(a.prototype,"constructor",{writable:!0,configurable:!0,enumerable:!1,value:a});return a}()};function Y(b,a,c){function d(a){return function(c){for(var d=[],e=0;e<arguments.length;++e)d[e]=arguments[e];e=[];for(var f=0,p=[],x=0,l=0,r=d.length;l<r;l++){var u=d[l];u instanceof Element&&m(u)&&(p[x++]=u);if(u instanceof DocumentFragment)for(u=u.firstChild;u;u=u.nextSibling)e[f++]=u;else e[f++]=u}a.apply(this,d);d=0;for(f=p.length;d<f;d++)C(b,p[d]);if(m(this))for(p=0,d=e.length;p<d;p++)f=e[p],f instanceof Element&&A(b,f)}}void 0!==c.h&&(a.prepend=d(c.h));void 0!==c.append&&(a.append=d(c.append))}
;function ua(){var b=X;v(Document.prototype,"createElement",function(a){if(this.__CE_hasRegistry){var c=b.a.get(a);if(c)return new c.constructorFunction}a=I.call(this,a);z(b,a);return a});v(Document.prototype,"importNode",function(a,c){a=ha.call(this,a,!!c);this.__CE_hasRegistry?D(b,a):y(b,a);return a});v(Document.prototype,"createElementNS",function(a,c){if(this.__CE_hasRegistry&&(null===a||"http://www.w3.org/1999/xhtml"===a)){var d=b.a.get(c);if(d)return new d.constructorFunction}a=J.call(this,a,
c);z(b,a);return a});Y(b,Document.prototype,{h:ia,append:ja})};function va(){var b=X;v(Node.prototype,"insertBefore",function(a,c){if(a instanceof DocumentFragment){var d=Array.prototype.slice.apply(a.childNodes);a=M.call(this,a,c);if(m(this)){c=0;for(var e=d.length;c<e;c++)A(b,d[c])}return a}d=m(a);c=M.call(this,a,c);d&&C(b,a);m(this)&&A(b,a);return c});v(Node.prototype,"appendChild",function(a){if(a instanceof DocumentFragment){var c=Array.prototype.slice.apply(a.childNodes);a=L.call(this,a);if(m(this))for(var d=0,e=c.length;d<e;d++)A(b,c[d]);return a}c=m(a);
d=L.call(this,a);c&&C(b,a);m(this)&&A(b,a);return d});v(Node.prototype,"cloneNode",function(a){a=K.call(this,!!a);this.ownerDocument.__CE_hasRegistry?D(b,a):y(b,a);return a});v(Node.prototype,"removeChild",function(a){var c=m(a),d=N.call(this,a);c&&C(b,a);return d});v(Node.prototype,"replaceChild",function(a,c){if(a instanceof DocumentFragment){var d=Array.prototype.slice.apply(a.childNodes);a=O.call(this,a,c);if(m(this)){C(b,c);c=0;for(var e=d.length;c<e;c++)A(b,d[c])}return a}d=m(a);e=O.call(this,
a,c);var f=m(this);f&&C(b,c);d&&C(b,a);f&&A(b,a);return e})};function wa(b){function a(a){return function(c){for(var d=[],e=0;e<arguments.length;++e)d[e]=arguments[e];e=[];for(var h=0,n=[],p=0,x=0,l=d.length;x<l;x++){var r=d[x];r instanceof Element&&m(r)&&(n[p++]=r);if(r instanceof DocumentFragment)for(r=r.firstChild;r;r=r.nextSibling)e[h++]=r;else e[h++]=r}a.apply(this,d);d=0;for(h=n.length;d<h;d++)C(b,n[d]);if(m(this))for(n=0,d=e.length;n<d;n++)h=e[n],h instanceof Element&&A(b,h)}}var c=Element.prototype;void 0!==T&&(c.before=a(T));void 0!==T&&(c.after=a(oa));
void 0!==U&&v(c,"replaceWith",function(a){for(var c=[],d=0;d<arguments.length;++d)c[d]=arguments[d];d=[];for(var g=0,h=[],n=0,p=0,x=c.length;p<x;p++){var l=c[p];l instanceof Element&&m(l)&&(h[n++]=l);if(l instanceof DocumentFragment)for(l=l.firstChild;l;l=l.nextSibling)d[g++]=l;else d[g++]=l}g=m(this);U.apply(this,c);c=0;for(n=h.length;c<n;c++)C(b,h[c]);if(g)for(C(b,this),h=0,c=d.length;h<c;h++)g=d[h],g instanceof Element&&A(b,g)});void 0!==V&&v(c,"remove",function(){var a=m(this);V.call(this);a&&
C(b,this)})};function xa(){function b(a,b){try{Object.defineProperty(a,"innerHTML",{enumerable:b.enumerable,configurable:!0,get:b.get,set:function(a){var c=this,e=void 0,f=0;m(this)&&(e=[],t(this,function(a){a!==c&&(e[f++]=a)}));b.set.call(this,a);if(e)for(var g=0;g<f;g++){var l=e[g];1===l.__CE_state&&d.disconnectedCallback(l)}this.ownerDocument.__CE_hasRegistry?D(d,this):y(d,this);return a}})}catch(g){}}function a(a,b){v(a,"insertAdjacentElement",function(a,c){var e=m(c);a=b.call(this,a,c);e&&C(d,c);m(a)&&A(d,
c);return a})}function c(a,b){function c(a,b){for(var c=[],e=0;a!==b;a=a.nextSibling)c[e++]=a;for(b=0;b<e;b++)D(d,c[b])}v(a,"insertAdjacentHTML",function(a,d){a=a.toLowerCase();if("beforebegin"===a){var e=this.previousSibling;b.call(this,a,d);c(e||this.parentNode.firstChild,this)}else if("afterbegin"===a)e=this.firstChild,b.call(this,a,d),c(this.firstChild,e);else if("beforeend"===a)e=this.lastChild,b.call(this,a,d),c(e||this.firstChild,null);else if("afterend"===a)e=this.nextSibling,b.call(this,
a,d),c(this.nextSibling,e);else throw new SyntaxError("The value provided ("+String(a)+") is not one of 'beforebegin', 'afterbegin', 'beforeend', or 'afterend'.");})}var d=X;P&&v(Element.prototype,"attachShadow",function(a){return this.__CE_shadowRoot=a=P.call(this,a)});Q&&Q.get?b(Element.prototype,Q):W&&W.get?b(HTMLElement.prototype,W):da(d,function(a){b(a,{enumerable:!0,configurable:!0,get:function(){return K.call(this,!0).innerHTML},set:function(a){var b="template"===this.localName,c=b?this.content:
this,d=J.call(document,this.namespaceURI,this.localName);for(d.innerHTML=a;0<c.childNodes.length;)N.call(c,c.childNodes[0]);for(a=b?d.content:d;0<a.childNodes.length;)L.call(c,a.childNodes[0])}})});qa?a(HTMLElement.prototype,qa):R?a(Element.prototype,R):console.warn("Custom Elements: `Element#insertAdjacentElement` was not patched.");ra?c(HTMLElement.prototype,ra):S?c(Element.prototype,S):console.warn("Custom Elements: `Element#insertAdjacentHTML` was not patched.");Y(d,Element.prototype,{h:ma,append:na});
wa(d)};var Z=window.customElements;if(!Z||Z.forcePolyfill||"function"!=typeof Z.define||"function"!=typeof Z.get){var X=new w;ta();ua();Y(X,DocumentFragment.prototype,{h:ka,append:la});va();xa();document.__CE_hasRegistry=!0;var customElements=new H(X);Object.defineProperty(window,"customElements",{configurable:!0,enumerable:!0,value:customElements})};
}).call(self);
//# sourceMappingURL=custom-elements.min.js.map