@adobe/coral-spectrum
Version:
Coral Spectrum is a JavaScript library of Web Components following Spectrum design patterns.
44 lines (42 loc) • 18.5 kB
JavaScript
(function(){
var g=new function(){};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(" "));function k(b){var a=aa.has(b);b=/^[a-z][.0-9_a-z]*-[\-.0-9_a-z]*$/.test(b);return!a&&b}function l(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 m(b,a){for(;a&&a!==b&&!a.nextSibling;)a=a.parentNode;return a&&a!==b?a.nextSibling:null}
function n(b,a,d){d=d?d:new Set;for(var c=b;c;){if(c.nodeType===Node.ELEMENT_NODE){var e=c;a(e);var h=e.localName;if("link"===h&&"import"===e.getAttribute("rel")){c=e.import;if(c instanceof Node&&!d.has(c))for(d.add(c),c=c.firstChild;c;c=c.nextSibling)n(c,a,d);c=m(b,e);continue}else if("template"===h){c=m(b,e);continue}if(e=e.__CE_shadowRoot)for(e=e.firstChild;e;e=e.nextSibling)n(e,a,d)}c=c.firstChild?c.firstChild:m(b,c)}}function p(b,a,d){b[a]=d};function q(){this.a=new Map;this.f=new Map;this.m=[];this.b=!1}function ba(b,a,d){b.a.set(a,d);b.f.set(d.constructor,d)}function r(b,a){b.b=!0;b.m.push(a)}function v(b,a){b.b&&n(a,function(a){return w(b,a)})}function w(b,a){if(b.b&&!a.__CE_patched){a.__CE_patched=!0;for(var d=0;d<b.m.length;d++)b.m[d](a)}}function x(b,a){var d=[];n(a,function(b){return d.push(b)});for(a=0;a<d.length;a++){var c=d[a];1===c.__CE_state?b.connectedCallback(c):y(b,c)}}
function z(b,a){var d=[];n(a,function(b){return d.push(b)});for(a=0;a<d.length;a++){var c=d[a];1===c.__CE_state&&b.disconnectedCallback(c)}}
function A(b,a,d){d=d?d:new Set;var c=[];n(a,function(e){var a;if("link"===e.localName&&"import"===e.getAttribute("rel"))a=e.import,a instanceof Node&&"complete"===a.readyState?(a.__CE_isImportDocument=!0,a.__CE_hasRegistry=!0):e.addEventListener("load",function(){var a=e.import;a.__CE_documentLoadHandled||(a.__CE_documentLoadHandled=!0,a.__CE_isImportDocument=!0,a.__CE_hasRegistry=!0,d.delete(a),A(b,a,d))});else{if(a=e.getAttribute("is"))e.__CE_is=a;c.push(e)}},d);if(b.b)for(a=0;a<c.length;a++)w(b,
c[a]);for(a=0;a<c.length;a++)y(b,c[a])}
function y(b,a){if(void 0===a.__CE_state){var d=b.a.get(a.__CE_is||a.localName);if(d=d&&d.localName===a.localName?d:null){d.constructionStack.push(a);var c=d.constructor;try{try{if(new c!==a)throw Error("The custom element constructor did not produce the element being upgraded.");}finally{d.constructionStack.pop()}}catch(f){throw a.__CE_state=2,f;}a.__CE_state=1;a.__CE_definition=d;if(d.attributeChangedCallback)for(d=d.observedAttributes,c=0;c<d.length;c++){var e=d[c],h=a.getAttribute(e);null!==h&&
b.attributeChangedCallback(a,e,null,h,null)}l(a)&&b.connectedCallback(a)}}}q.prototype.connectedCallback=function(b){var a=b.__CE_definition;a.connectedCallback&&a.connectedCallback.call(b)};q.prototype.disconnectedCallback=function(b){var a=b.__CE_definition;a.disconnectedCallback&&a.disconnectedCallback.call(b)};
q.prototype.attributeChangedCallback=function(b,a,d,c,e){var h=b.__CE_definition;h.attributeChangedCallback&&-1<h.observedAttributes.indexOf(a)&&h.attributeChangedCallback.call(b,a,d,c,e)};function B(b,a){this.c=b;this.a=a;this.b=void 0;A(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 C(b){b.b&&b.b.disconnect()}B.prototype.f=function(b){var a=this.a.readyState;"interactive"!==a&&"complete"!==a||C(this);for(a=0;a<b.length;a++)for(var d=b[a].addedNodes,c=0;c<d.length;c++)A(this.c,d[c])};function ca(){var b=this;this.b=this.a=void 0;this.f=new Promise(function(a){b.b=a;b.a&&a(b.a)})}function D(b){if(b.a)throw Error("Already resolved.");b.a=void 0;b.b&&b.b(void 0)};function E(b){this.i=!1;this.c=b;this.l=new Map;this.j=function(b){return b()};this.g=!1;this.h=[];this.s=new B(b,document)}
E.prototype.define=function(b,a,d){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.c.a.get(b))throw Error("A custom element with name '"+b+"' has already been defined.");var e=b;if(d&&d.extends){if(!this.enableCustomizedBuiltins)throw Error("Customized builtin elements are disabled by default. Set customElements.enableCustomizedBuiltins = true.");if(k(d.extends))throw Error("A customized builtin element may not extend a custom element.");
if(document.createElement(d.extends)instanceof window.HTMLUnknownElement)throw Error("Cannot extend '"+d.extends+"': is not a real HTML element");e=d.extends}if(this.i)throw Error("A custom element is already being defined.");this.i=!0;var h,f,u,t,P;try{d=function(b){var a=Q[b];if(void 0!==a&&!(a instanceof Function))throw Error("The '"+b+"' callback must be a function.");return a};var Q=a.prototype;if(!(Q instanceof Object))throw new TypeError("The custom element constructor's prototype is not an object.");
h=d("connectedCallback");f=d("disconnectedCallback");u=d("adoptedCallback");t=d("attributeChangedCallback");P=a.observedAttributes||[]}catch(xa){return}finally{this.i=!1}ba(this.c,b,{name:b,localName:e,constructor:a,connectedCallback:h,disconnectedCallback:f,adoptedCallback:u,attributeChangedCallback:t,observedAttributes:P,constructionStack:[]});this.h.push(b);this.g||(this.g=!0,this.j(function(){if(!1!==c.g)for(c.g=!1,A(c.c,document);0<c.h.length;){var b=c.h.shift();(b=c.l.get(b))&&D(b)}}))};
E.prototype.get=function(b){if(b=this.c.a.get(b))return b.constructor};E.prototype.upgradeElement=function(b){y(this.c,b)};E.prototype.whenDefined=function(b){if(!k(b))return Promise.reject(new SyntaxError("'"+b+"' is not a valid custom element name."));var a=this.l.get(b);if(a)return a.f;a=new ca;this.l.set(b,a);this.c.a.get(b)&&-1===this.h.indexOf(b)&&D(a);return a.f};E.prototype.u=function(b){C(this.s);var a=this.j;this.j=function(d){return b(function(){return a(d)})}};window.CustomElementRegistry=E;E.prototype.define=E.prototype.define;
E.prototype.get=E.prototype.get;E.prototype.whenDefined=E.prototype.whenDefined;E.prototype.upgrade=E.prototype.upgradeElement;E.prototype.polyfillWrapFlushCallback=E.prototype.u;var F=window.Document.prototype.createElement,da=window.Document.prototype.createElementNS,ea=window.Document.prototype.importNode,fa=window.Document.prototype.prepend,ga=window.Document.prototype.append,G=window.Node.prototype.cloneNode,H=window.Node.prototype.appendChild,I=window.Node.prototype.insertBefore,J=window.Node.prototype.removeChild,K=window.Node.prototype.replaceChild,L=Object.getOwnPropertyDescriptor(window.Node.prototype,"textContent"),M=window.Element.prototype.attachShadow,N=Object.getOwnPropertyDescriptor(window.Element.prototype,
"innerHTML"),O=window.Element.prototype.getAttribute,R=window.Element.prototype.setAttribute,S=window.Element.prototype.removeAttribute,T=window.Element.prototype.getAttributeNS,U=window.Element.prototype.setAttributeNS,V=window.Element.prototype.removeAttributeNS,W=window.Element.prototype.insertAdjacentElement,ha=window.Element.prototype.prepend,ia=window.Element.prototype.append,ja=window.Element.prototype.before,ka=window.Element.prototype.after,la=window.Element.prototype.replaceWith,ma=window.Element.prototype.remove,
na=window.HTMLElement,X=Object.getOwnPropertyDescriptor(window.HTMLElement.prototype,"innerHTML"),oa=window.HTMLElement.prototype.insertAdjacentElement,pa={Button:window.HTMLButtonElement,Canvas:window.HTMLCanvasElement,Data:window.HTMLDataElement,Head:window.HTMLHeadElement,Mod:window.HTMLModElement,TableCell:window.HTMLTableCellElement,TableCol:window.HTMLTableColElement,Anchor:window.HTMLAnchorElement,Area:window.HTMLAreaElement,Base:window.HTMLBaseElement,Body:window.HTMLBodyElement,BR:window.HTMLBRElement,
DataList:window.HTMLDataListElement,Details:window.HTMLDetailsElement,Dialog:window.HTMLDialogElement,Div:window.HTMLDivElement,DList:window.HTMLDListElement,Embed:window.HTMLEmbedElement,FieldSet:window.HTMLFieldSetElement,Form:window.HTMLFormElement,Heading:window.HTMLHeadingElement,HR:window.HTMLHRElement,Html:window.HTMLHtmlElement,IFrame:window.HTMLIFrameElement,Image:window.HTMLImageElement,Input:window.HTMLInputElement,Keygen:window.HTMLKeygenElement,Label:window.HTMLLabelElement,Legend:window.HTMLLegendElement,
LI:window.HTMLLIElement,Link:window.HTMLLinkElement,Map:window.HTMLMapElement,Media:window.HTMLMediaElement,Menu:window.HTMLMenuElement,MenuItem:window.HTMLMenuItemElement,Meta:window.HTMLMetaElement,Meter:window.HTMLMeterElement,Object:window.HTMLObjectElement,OList:window.HTMLOListElement,OptGroup:window.HTMLOptGroupElement,Option:window.HTMLOptionElement,Output:window.HTMLOutputElement,Paragraph:window.HTMLParagraphElement,Param:window.HTMLParamElement,Picture:window.HTMLPictureElement,Pre:window.HTMLPreElement,
Progress:window.HTMLProgressElement,Quote:window.HTMLQuoteElement,Script:window.HTMLScriptElement,Select:window.HTMLSelectElement,Slot:window.HTMLSlotElement,Source:window.HTMLSourceElement,Span:window.HTMLSpanElement,Style:window.HTMLStyleElement,TableCaption:window.HTMLTableCaptionElement,Table:window.HTMLTableElement,TableRow:window.HTMLTableRowElement,TableSection:window.HTMLTableSectionElement,Template:window.HTMLTemplateElement,TextArea:window.HTMLTextAreaElement,Time:window.HTMLTimeElement,
Title:window.HTMLTitleElement,Track:window.HTMLTrackElement,UList:window.HTMLUListElement,Unknown:window.HTMLUnknownElement};function qa(){var b=Y;window.HTMLElement=function(){function a(){var a=this.constructor,c=b.f.get(a);if(!c)throw Error("The custom element being constructed was not registered with `customElements`.");var e=c.constructionStack;if(!e.length)return e=F.call(document,c.localName),Object.setPrototypeOf(e,a.prototype),e.__CE_state=1,e.__CE_definition=c,w(b,e),e;var c=e.length-1,h=e[c];if(h===g)throw Error("The HTMLElement constructor was either called reentrantly for this constructor or called multiple times.");
e[c]=g;Object.setPrototypeOf(h,a.prototype);w(b,h);return h}a.prototype=na.prototype;return a}()};function ra(){var b=Y;function a(a,e){e&&(window[a]=function(){function d(){var e=this.constructor,d=b.f.get(e);if(!d)throw Error("The custom element being constructed was not registered with `customElements`.");var c=d.constructionStack;if(!c.length)return c=F.call(document,d.localName),c.setAttribute("is",d.name),Object.setPrototypeOf(c,e.prototype),c.__CE_state=1,c.__CE_definition=d,w(b,c),c;var d=c.length-1,h=c[d];if(h===g)throw Error("The "+a+" constructor was either called reentrantly for this constructor or called multiple times.");
c[d]=g;Object.setPrototypeOf(h,e.prototype);w(b,h);return h}d.prototype=e.prototype;return d}())}for(var d in pa)a("HTML"+d+"Element",pa[d])};function sa(b,a,d){a.prepend=function(a){for(var e=[],c=0;c<arguments.length;++c)e[c-0]=arguments[c];c=e.filter(function(b){return b instanceof Node&&l(b)});d.o.apply(this,e);for(var f=0;f<c.length;f++)z(b,c[f]);if(l(this))for(c=0;c<e.length;c++)f=e[c],f instanceof Element&&x(b,f)};a.append=function(a){for(var e=[],c=0;c<arguments.length;++c)e[c-0]=arguments[c];c=e.filter(function(b){return b instanceof Node&&l(b)});d.append.apply(this,e);for(var f=0;f<c.length;f++)z(b,c[f]);if(l(this))for(c=0;c<
e.length;c++)f=e[c],f instanceof Element&&x(b,f)}};function ta(){var b=Y;p(Document.prototype,"createElement",function(a,d){if(this.__CE_hasRegistry){var c=b.a.get(d&&d.is?d.is:a);if(c)return new c.constructor}a=F.call(this,a);d&&d.is&&(a.__CE_is=d.is,a.setAttribute("is",d.is));w(b,a);return a});p(Document.prototype,"importNode",function(a,d){a=ea.call(this,a,d);this.__CE_hasRegistry?A(b,a):v(b,a);return a});p(Document.prototype,"createElementNS",function(a,d,c){if(this.__CE_hasRegistry&&(null===a||"http://www.w3.org/1999/xhtml"===a)){var e=b.a.get(c&&
c.is?c.is:d);if(e)return new e.constructor}a=da.call(this,a,d);c&&c.is&&(a.__CE_is=c.is,a.setAttribute("is",c.is));w(b,a);return a});sa(b,Document.prototype,{o:fa,append:ga})};function ua(){var b=Y;function a(a,c){Object.defineProperty(a,"textContent",{enumerable:c.enumerable,configurable:!0,get:c.get,set:function(a){if(this.nodeType===Node.TEXT_NODE)c.set.call(this,a);else{var e=void 0;if(this.firstChild){var d=this.childNodes,u=d.length;if(0<u&&l(this))for(var e=Array(u),t=0;t<u;t++)e[t]=d[t]}c.set.call(this,a);if(e)for(a=0;a<e.length;a++)z(b,e[a])}}})}p(Node.prototype,"insertBefore",function(a,c){if(a instanceof DocumentFragment){var e=Array.prototype.slice.apply(a.childNodes);
a=I.call(this,a,c);if(l(this))for(c=0;c<e.length;c++)x(b,e[c]);return a}e=l(a);c=I.call(this,a,c);e&&z(b,a);l(this)&&x(b,a);return c});p(Node.prototype,"appendChild",function(a){if(a instanceof DocumentFragment){var c=Array.prototype.slice.apply(a.childNodes);a=H.call(this,a);if(l(this))for(var e=0;e<c.length;e++)x(b,c[e]);return a}c=l(a);e=H.call(this,a);c&&z(b,a);l(this)&&x(b,a);return e});p(Node.prototype,"cloneNode",function(a){a=G.call(this,a);this.ownerDocument.__CE_hasRegistry?A(b,a):v(b,a);
return a});p(Node.prototype,"removeChild",function(a){var c=l(a),e=J.call(this,a);c&&z(b,a);return e});p(Node.prototype,"replaceChild",function(a,c){if(a instanceof DocumentFragment){var e=Array.prototype.slice.apply(a.childNodes);a=K.call(this,a,c);if(l(this))for(z(b,c),c=0;c<e.length;c++)x(b,e[c]);return a}var e=l(a),d=K.call(this,a,c),f=l(this);f&&z(b,c);e&&z(b,a);f&&x(b,a);return d});L&&L.get?a(Node.prototype,L):r(b,function(b){a(b,{enumerable:!0,configurable:!0,get:function(){for(var a=[],b=
0;b<this.childNodes.length;b++)a.push(this.childNodes[b].textContent);return a.join("")},set:function(a){for(;this.firstChild;)J.call(this,this.firstChild);H.call(this,document.createTextNode(a))}})})};function va(b){var a=Element.prototype;a.before=function(a){for(var c=[],e=0;e<arguments.length;++e)c[e-0]=arguments[e];e=c.filter(function(a){return a instanceof Node&&l(a)});ja.apply(this,c);for(var d=0;d<e.length;d++)z(b,e[d]);if(l(this))for(e=0;e<c.length;e++)d=c[e],d instanceof Element&&x(b,d)};a.after=function(a){for(var c=[],e=0;e<arguments.length;++e)c[e-0]=arguments[e];e=c.filter(function(a){return a instanceof Node&&l(a)});ka.apply(this,c);for(var d=0;d<e.length;d++)z(b,e[d]);if(l(this))for(e=
0;e<c.length;e++)d=c[e],d instanceof Element&&x(b,d)};a.replaceWith=function(a){for(var c=[],e=0;e<arguments.length;++e)c[e-0]=arguments[e];var e=c.filter(function(a){return a instanceof Node&&l(a)}),d=l(this);la.apply(this,c);for(var f=0;f<e.length;f++)z(b,e[f]);if(d)for(z(b,this),e=0;e<c.length;e++)d=c[e],d instanceof Element&&x(b,d)};a.remove=function(){var a=l(this);ma.call(this);a&&z(b,this)}};function wa(){var b=Y;function a(a,c){Object.defineProperty(a,"innerHTML",{enumerable:c.enumerable,configurable:!0,get:c.get,set:function(a){var e=this,d=void 0;l(this)&&(d=[],n(this,function(a){a!==e&&d.push(a)}));c.set.call(this,a);if(d)for(var h=0;h<d.length;h++){var f=d[h];1===f.__CE_state&&b.disconnectedCallback(f)}this.ownerDocument.__CE_hasRegistry?A(b,this):v(b,this);return a}})}function d(a,c){p(a,"insertAdjacentElement",function(a,e){var d=l(e);a=c.call(this,a,e);d&&z(b,e);l(a)&&x(b,e);
return a})}M?p(Element.prototype,"attachShadow",function(a){return this.__CE_shadowRoot=a=M.call(this,a)}):console.warn("Custom Elements: `Element#attachShadow` was not patched.");if(N&&N.get)a(Element.prototype,N);else if(X&&X.get)a(HTMLElement.prototype,X);else{var c=F.call(document,"div");r(b,function(b){a(b,{enumerable:!0,configurable:!0,get:function(){return G.call(this,!0).innerHTML},set:function(a){var b="template"===this.localName?this.content:this;for(c.innerHTML=a;0<b.childNodes.length;)J.call(b,
b.childNodes[0]);for(;0<c.childNodes.length;)H.call(b,c.childNodes[0])}})})}p(Element.prototype,"setAttribute",function(a,c){if(1!==this.__CE_state)return R.call(this,a,c);var e=O.call(this,a);R.call(this,a,c);c=O.call(this,a);b.attributeChangedCallback(this,a.toLowerCase(),e,c,null)});p(Element.prototype,"setAttributeNS",function(a,c,d){if(1!==this.__CE_state)return U.call(this,a,c,d);var e=T.call(this,a,c);U.call(this,a,c,d);d=T.call(this,a,c);b.attributeChangedCallback(this,c,e,d,a)});p(Element.prototype,"removeAttribute",
function(a){if(1!==this.__CE_state)return S.call(this,a);var c=O.call(this,a);S.call(this,a);null!==c&&b.attributeChangedCallback(this,a.toLowerCase(),c,null,null)});p(Element.prototype,"removeAttributeNS",function(a,c){if(1!==this.__CE_state)return V.call(this,a,c);var d=T.call(this,a,c);V.call(this,a,c);var e=T.call(this,a,c);d!==e&&b.attributeChangedCallback(this,c,d,e,a)});oa?d(HTMLElement.prototype,oa):W?d(Element.prototype,W):console.warn("Custom Elements: `Element#insertAdjacentElement` was not patched.");
sa(b,Element.prototype,{o:ha,append:ia});va(b)};/*
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
*/
var Z=window.customElements;if(!Z||Z.forcePolyfill||"function"!=typeof Z.define||"function"!=typeof Z.get){var Y=new q;qa();ra();ta();ua();wa();document.__CE_hasRegistry=!0;var customElements=new E(Y);customElements.enableCustomizedBuiltins=true;Object.defineProperty(window,"customElements",{configurable:!0,enumerable:!0,value:customElements})};
}).call(self);