From 68c650f06f45ac9d10f26e99b1fdb122d9eb8340 Mon Sep 17 00:00:00 2001 From: Russell Bicknell Date: Fri, 9 Jun 2017 14:39:10 -0700 Subject: [PATCH 01/92] Gather all external API in 'Environment.js'; update top-level files. --- src/CustomElementInternals.js | 7 ++-- src/DocumentConstructionObserver.js | 13 ++++---- src/Environment.js | 17 ++++++++++ src/EnvironmentProxy.js | 52 +++++++++++++++++++++++++++++ src/Utilities.js | 24 +++++++------ 5 files changed, 93 insertions(+), 20 deletions(-) create mode 100644 src/Environment.js create mode 100644 src/EnvironmentProxy.js diff --git a/src/CustomElementInternals.js b/src/CustomElementInternals.js index 3f08897..755d16b 100644 --- a/src/CustomElementInternals.js +++ b/src/CustomElementInternals.js @@ -1,3 +1,4 @@ +import * as EnvProxy from './EnvironmentProxy.js'; import * as Utilities from './Utilities.js'; import CEState from './CustomElementState.js'; @@ -173,7 +174,7 @@ export default class CustomElementInternals { const elements = []; const gatherElements = element => { - if (element.localName === 'link' && element.getAttribute('rel') === 'import') { + if (EnvProxy.localName(element) === 'link' && EnvProxy.getAttribute(element, 'rel') === 'import') { // The HTML Imports polyfill sets a descendant element of the link to // the `import` property, specifically this is *not* a Document. const importNode = /** @type {?Node} */ (element.import); @@ -186,7 +187,7 @@ export default class CustomElementInternals { } else { // If this link's import root is not available, its contents can't be // walked. Wait for 'load' and walk it when it's ready. - element.addEventListener('load', () => { + EnvProxy.addEventListener(element, 'load', () => { const importNode = /** @type {!Node} */ (element.import); if (importNode.__CE_documentLoadHandled) return; @@ -262,7 +263,7 @@ export default class CustomElementInternals { const observedAttributes = definition.observedAttributes; for (let i = 0; i < observedAttributes.length; i++) { const name = observedAttributes[i]; - const value = element.getAttribute(name); + const value = EnvProxy.getAttribute(element, name); if (value !== null) { this.attributeChangedCallback(element, name, null, value, null); } diff --git a/src/DocumentConstructionObserver.js b/src/DocumentConstructionObserver.js index b150d36..f810f32 100644 --- a/src/DocumentConstructionObserver.js +++ b/src/DocumentConstructionObserver.js @@ -1,3 +1,4 @@ +import * as EnvProxy from './EnvironmentProxy.js'; import CustomElementInternals from './CustomElementInternals.js'; export default class DocumentConstructionObserver { @@ -22,14 +23,14 @@ export default class DocumentConstructionObserver { // document. this._internals.patchAndUpgradeTree(this._document); - if (this._document.readyState === 'loading') { - this._observer = new MutationObserver(this._handleMutations.bind(this)); + if (EnvProxy.readyState(this._document) === 'loading') { + this._observer = new EnvProxy.MutationObserver(this._handleMutations.bind(this)); // Nodes created by the parser are given to the observer *before* the next // task runs. Inline scripts are run in a new task. This means that the // observer will be able to handle the newly parsed nodes before the inline // script is run. - this._observer.observe(this._document, { + EnvProxy.observe(this._observer, this._document, { childList: true, subtree: true, }); @@ -38,7 +39,7 @@ export default class DocumentConstructionObserver { disconnect() { if (this._observer) { - this._observer.disconnect(); + EnvProxy.disconnect(this._observer); } } @@ -49,13 +50,13 @@ export default class DocumentConstructionObserver { // Once the document's `readyState` is 'interactive' or 'complete', all new // nodes created within that document will be the result of script and // should be handled by patching. - const readyState = this._document.readyState; + const readyState = EnvProxy.readyState(this._document); if (readyState === 'interactive' || readyState === 'complete') { this.disconnect(); } for (let i = 0; i < mutations.length; i++) { - const addedNodes = mutations[i].addedNodes; + const addedNodes = EnvProxy.addedNodes(mutations[i]); for (let j = 0; j < addedNodes.length; j++) { const node = addedNodes[j]; this._internals.patchAndUpgradeTree(node); diff --git a/src/Environment.js b/src/Environment.js new file mode 100644 index 0000000..254861b --- /dev/null +++ b/src/Environment.js @@ -0,0 +1,17 @@ +function getOwnPropertyDescriptors(target) { + const clone = {}; + + const keys = Object.getOwnPropertyNames(target); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + clone[key] = Object.getOwnPropertyDescriptor(target, key); + } + + return clone; +} + +export const Document = getOwnPropertyDescriptors(window.Document.prototype); +export const Element = getOwnPropertyDescriptors(window.Element.prototype); +export const MutationObserver = getOwnPropertyDescriptors(window.MutationObserver.prototype); +export const MutationRecord = getOwnPropertyDescriptors(window.MutationRecord.prototype); +export const Node = getOwnPropertyDescriptors(window.Node.prototype); diff --git a/src/EnvironmentProxy.js b/src/EnvironmentProxy.js new file mode 100644 index 0000000..9c56c54 --- /dev/null +++ b/src/EnvironmentProxy.js @@ -0,0 +1,52 @@ +import * as Env from './Environment.js'; + +const getter = descriptor => descriptor ? descriptor.get : () => undefined; +const method = descriptor => descriptor ? descriptor.value : () => undefined; + +// Document + +const readyStateGetter = getter(Env.Document.readyState); +export const readyState = (node, attrName) => readyStateGetter.call(node, attrName); + +// Element + +const getAttributeMethod = method(Env.Element.getAttribute); +export const getAttribute = (node, attrName) => getAttributeMethod.call(node, attrName); + +const localNameGetter = getter(Env.Element.localName); +export const localName = node => localNameGetter.call(node); + +// MutationObserver + +export const MutationObserver = method(Env.MutationObserver.constructor); + +const observeMethod = method(Env.MutationObserver.observe); +export const observe = (mutationObserver, target, options) => observeMethod.call(mutationObserver, target, options); + +const disconnectMethod = method(Env.MutationObserver.disconnect); +export const disconnect = mutationObserver => disconnectMethod.call(mutationObserver); + +// MutationRecord + +const addedNodesGetter = getter(Env.MutationRecord.addedNodes); +export const addedNodes = node => addedNodesGetter.call(node); + +// Node + +const addEventListenerMethod = method(Env.Node.addEventListener); +export const addEventListener = (node, type, callback, options) => addEventListenerMethod.call(node, type, callback, options); + +const firstChildGetter = getter(Env.Node.firstChild); +export const firstChild = node => firstChildGetter.call(node); + +const isConnectedGetter = getter(Env.Node.isConnected); +export const isConnected = node => isConnectedGetter.call(node); + +const nextSiblingGetter = getter(Env.Node.nextSibling); +export const nextSibling = node => nextSiblingGetter.call(node); + +const nodeTypeGetter = getter(Env.Node.nodeType); +export const nodeType = node => nodeTypeGetter.call(node); + +const parentNodeGetter = getter(Env.Node.parentNode); +export const parentNode = node => parentNodeGetter.call(node); diff --git a/src/Utilities.js b/src/Utilities.js index 6be1b72..2be39e2 100644 --- a/src/Utilities.js +++ b/src/Utilities.js @@ -1,3 +1,5 @@ +import * as EnvProxy from './EnvironmentProxy.js'; + const reservedTagList = new Set([ 'annotation-xml', 'color-profile', @@ -26,7 +28,7 @@ export function isValidCustomElementName(localName) { */ export function isConnected(node) { // Use `Node#isConnected`, if defined. - const nativeValue = node.isConnected; + const nativeValue = EnvProxy.isConnected(node); if (nativeValue !== undefined) { return nativeValue; } @@ -34,7 +36,7 @@ export function isConnected(node) { /** @type {?Node|undefined} */ let current = node; while (current && !(current.__CE_isImportDocument || current instanceof Document)) { - current = current.parentNode || (window.ShadowRoot && current instanceof ShadowRoot ? current.host : undefined); + current = EnvProxy.parentNode(current) || (window.ShadowRoot && current instanceof ShadowRoot ? current.host : undefined); } return !!(current && (current.__CE_isImportDocument || current instanceof Document)); } @@ -46,10 +48,10 @@ export function isConnected(node) { */ function nextSiblingOrAncestorSibling(root, start) { let node = start; - while (node && node !== root && !node.nextSibling) { - node = node.parentNode; + while (node && node !== root && !EnvProxy.nextSibling(node)) { + node = EnvProxy.parentNode(node); } - return (!node || node === root) ? null : node.nextSibling; + return (!node || node === root) ? null : EnvProxy.nextSibling(node); } /** @@ -58,7 +60,7 @@ function nextSiblingOrAncestorSibling(root, start) { * @return {?Node} */ function nextNode(root, start) { - return start.firstChild ? start.firstChild : nextSiblingOrAncestorSibling(root, start); + return EnvProxy.firstChild(start) || nextSiblingOrAncestorSibling(root, start); } /** @@ -69,13 +71,13 @@ function nextNode(root, start) { export function walkDeepDescendantElements(root, callback, visitedImports = new Set()) { let node = root; while (node) { - if (node.nodeType === Node.ELEMENT_NODE) { + if (EnvProxy.nodeType(node) === Node.ELEMENT_NODE) { const element = /** @type {!Element} */(node); callback(element); - const localName = element.localName; - if (localName === 'link' && element.getAttribute('rel') === 'import') { + const localName = EnvProxy.localName(element); + if (localName === 'link' && EnvProxy.getAttribute(element, 'rel') === 'import') { // If this import (polyfilled or not) has it's root node available, // walk it. const importNode = /** @type {!Node} */ (element.import); @@ -83,7 +85,7 @@ export function walkDeepDescendantElements(root, callback, visitedImports = new // Prevent multiple walks of the same import root. visitedImports.add(importNode); - for (let child = importNode.firstChild; child; child = child.nextSibling) { + for (let child = EnvProxy.firstChild(importNode); child; child = EnvProxy.nextSibling(child)) { walkDeepDescendantElements(child, callback, visitedImports); } } @@ -105,7 +107,7 @@ export function walkDeepDescendantElements(root, callback, visitedImports = new // Walk shadow roots. const shadowRoot = element.__CE_shadowRoot; if (shadowRoot) { - for (let child = shadowRoot.firstChild; child; child = child.nextSibling) { + for (let child = EnvProxy.firstChild(shadowRoot); child; child = EnvProxy.nextSibling(child)) { walkDeepDescendantElements(child, callback, visitedImports); } } From bf550a1559ae05560c3d418cd2a72f3a33c64eb3 Mon Sep 17 00:00:00 2001 From: Russell Bicknell Date: Fri, 9 Jun 2017 14:49:34 -0700 Subject: [PATCH 02/92] Document: replace 'Native.js' use with 'Environment.js'. --- src/EnvironmentProxy.js | 11 ++++++++++- src/Patch/Document.js | 13 +++++++------ src/Patch/Native.js | 12 +++++++----- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/EnvironmentProxy.js b/src/EnvironmentProxy.js index 9c56c54..cc2fc01 100644 --- a/src/EnvironmentProxy.js +++ b/src/EnvironmentProxy.js @@ -5,8 +5,17 @@ const method = descriptor => descriptor ? descriptor.value : () => undefined; // Document +const createElementMethod = method(Env.Document.createElement); +export const createElement = (doc, localName) => createElementMethod.call(doc, localName); + +const createElementNSMethod = method(Env.Document.createElementNS); +export const createElementNS = (doc, namespace, qualifiedName) => createElementNSMethod.call(doc, namespace, qualifiedName); + +const importNodeMethod = method(Env.Document.importNode); +export const importNode = (doc, node, deep) => importNodeMethod.call(doc, node, deep); + const readyStateGetter = getter(Env.Document.readyState); -export const readyState = (node, attrName) => readyStateGetter.call(node, attrName); +export const readyState = doc => readyStateGetter.call(doc); // Element diff --git a/src/Patch/Document.js b/src/Patch/Document.js index f764362..28cedc3 100644 --- a/src/Patch/Document.js +++ b/src/Patch/Document.js @@ -1,4 +1,5 @@ -import Native from './Native.js'; +import * as Env from '../Environment.js'; +import * as EnvProxy from '../EnvironmentProxy.js'; import CustomElementInternals from '../CustomElementInternals.js'; import * as Utilities from '../Utilities.js'; @@ -24,7 +25,7 @@ export default function(internals) { } const result = /** @type {!Element} */ - (Native.Document_createElement.call(this, localName)); + EnvProxy.createElement(this, localName); internals.patch(result); return result; }); @@ -37,7 +38,7 @@ export default function(internals) { * @return {!Node} */ function(node, deep) { - const clone = Native.Document_importNode.call(this, node, deep); + const clone = EnvProxy.importNode(this, node, deep); // Only create custom elements if this document is associated with the registry. if (!this.__CE_hasRegistry) { internals.patchTree(clone); @@ -66,13 +67,13 @@ export default function(internals) { } const result = /** @type {!Element} */ - (Native.Document_createElementNS.call(this, namespace, localName)); + EnvProxy.createElementNS(this, namespace, localName); internals.patch(result); return result; }); PatchParentNode(internals, Document.prototype, { - prepend: Native.Document_prepend, - append: Native.Document_append, + prepend: (Env.Document.prepend || {}).value, + append: (Env.Document.append || {}).value, }); }; diff --git a/src/Patch/Native.js b/src/Patch/Native.js index 8b761f3..ce47975 100644 --- a/src/Patch/Native.js +++ b/src/Patch/Native.js @@ -1,9 +1,11 @@ +import * as Env from '../Environment.js'; + export default { - Document_createElement: window.Document.prototype.createElement, - Document_createElementNS: window.Document.prototype.createElementNS, - Document_importNode: window.Document.prototype.importNode, - Document_prepend: window.Document.prototype['prepend'], - Document_append: window.Document.prototype['append'], + Document_createElement: Env.Document.createElement.value, + Document_createElementNS: Env.Document.createElementNS.value, + Document_importNode: Env.Document.importNode.value, + Document_prepend: (Env.Document.prepend || {}).value, + Document_append: (Env.Document.append || {}).value, Node_cloneNode: window.Node.prototype.cloneNode, Node_appendChild: window.Node.prototype.appendChild, Node_insertBefore: window.Node.prototype.insertBefore, From d7538ce055c4dfca76ae26cf9835df120a8335af Mon Sep 17 00:00:00 2001 From: Russell Bicknell Date: Fri, 9 Jun 2017 15:52:01 -0700 Subject: [PATCH 03/92] Element: replace 'Native.js' use with 'Environment.js'. --- src/Environment.js | 2 + src/EnvironmentProxy.js | 37 +++++++++++++++++- src/Patch/Element.js | 84 ++++++++++++++++++++++------------------- src/Patch/Native.js | 36 +++++++++--------- 4 files changed, 101 insertions(+), 58 deletions(-) diff --git a/src/Environment.js b/src/Environment.js index 254861b..dad8a74 100644 --- a/src/Environment.js +++ b/src/Environment.js @@ -12,6 +12,8 @@ function getOwnPropertyDescriptors(target) { export const Document = getOwnPropertyDescriptors(window.Document.prototype); export const Element = getOwnPropertyDescriptors(window.Element.prototype); +export const HTMLElement = getOwnPropertyDescriptors(window.HTMLElement.prototype); +export const HTMLTemplateElement = getOwnPropertyDescriptors(window.HTMLElement.prototype); export const MutationObserver = getOwnPropertyDescriptors(window.MutationObserver.prototype); export const MutationRecord = getOwnPropertyDescriptors(window.MutationRecord.prototype); export const Node = getOwnPropertyDescriptors(window.Node.prototype); diff --git a/src/EnvironmentProxy.js b/src/EnvironmentProxy.js index cc2fc01..12f63fa 100644 --- a/src/EnvironmentProxy.js +++ b/src/EnvironmentProxy.js @@ -19,12 +19,35 @@ export const readyState = doc => readyStateGetter.call(doc); // Element +const attachShadowMethod = method(Env.Element.attachShadow); +export const attachShadow = (node, options) => attachShadowMethod.call(node, options); + const getAttributeMethod = method(Env.Element.getAttribute); -export const getAttribute = (node, attrName) => getAttributeMethod.call(node, attrName); +export const getAttribute = (node, name) => getAttributeMethod.call(node, name); + +const getAttributeNSMethod = method(Env.Element.getAttributeNS); +export const getAttributeNS = (node, ns, name, value) => getAttributeNSMethod.call(node, ns, name, value); const localNameGetter = getter(Env.Element.localName); export const localName = node => localNameGetter.call(node); +const removeAttributeMethod = method(Env.Element.removeAttribute); +export const removeAttribute = (node, name) => removeAttributeMethod.call(node, name); + +const removeAttributeNSMethod = method(Env.Element.removeAttributeNS); +export const removeAttributeNS = (node, ns, name) => removeAttributeNSMethod.call(node, ns, name); + +const setAttributeMethod = method(Env.Element.setAttribute); +export const setAttribute = (node, name, value) => setAttributeMethod.call(node, name, value); + +const setAttributeNSMethod = method(Env.Element.setAttributeNS); +export const setAttributeNS = (node, ns, name, value) => setAttributeNSMethod.call(node, ns, name, value); + +// HTMLTemplateElement + +const contentGetter = getter(Env.HTMLTemplateElement.content); +export const content = node => contentGetter.call(node); + // MutationObserver export const MutationObserver = method(Env.MutationObserver.constructor); @@ -45,6 +68,15 @@ export const addedNodes = node => addedNodesGetter.call(node); const addEventListenerMethod = method(Env.Node.addEventListener); export const addEventListener = (node, type, callback, options) => addEventListenerMethod.call(node, type, callback, options); +const appendChildMethod = method(Env.Node.appendChild); +export const appendChild = (node, deep) => appendChildMethod.call(node, deep); + +const childNodesGetter = getter(Env.Node.childNodes); +export const childNodes = node => childNodesGetter.call(node); + +const cloneNodeMethod = method(Env.Node.cloneNode); +export const cloneNode = (node, deep) => cloneNodeMethod.call(node, deep); + const firstChildGetter = getter(Env.Node.firstChild); export const firstChild = node => firstChildGetter.call(node); @@ -59,3 +91,6 @@ export const nodeType = node => nodeTypeGetter.call(node); const parentNodeGetter = getter(Env.Node.parentNode); export const parentNode = node => parentNodeGetter.call(node); + +const removeChildMethod = method(Env.Node.removeChild); +export const removeChild = (node, deep) => removeChildMethod.call(node, deep); diff --git a/src/Patch/Element.js b/src/Patch/Element.js index 27781d0..4057282 100644 --- a/src/Patch/Element.js +++ b/src/Patch/Element.js @@ -1,4 +1,5 @@ -import Native from './Native.js'; +import * as Env from '../Environment.js'; +import * as EnvProxy from '../EnvironmentProxy.js'; import CustomElementInternals from '../CustomElementInternals.js'; import CEState from '../CustomElementState.js'; import * as Utilities from '../Utilities.js'; @@ -10,7 +11,7 @@ import PatchChildNode from './Interface/ChildNode.js'; * @param {!CustomElementInternals} internals */ export default function(internals) { - if (Native.Element_attachShadow) { + if (Env.Element.attachShadow) { Utilities.setPropertyUnchecked(Element.prototype, 'attachShadow', /** * @this {Element} @@ -18,7 +19,7 @@ export default function(internals) { * @return {ShadowRoot} */ function(init) { - const shadowRoot = Native.Element_attachShadow.call(this, init); + const shadowRoot = EnvProxy.attachShadow(this, init); this.__CE_shadowRoot = shadowRoot; return shadowRoot; }); @@ -74,14 +75,16 @@ export default function(internals) { }); } - if (Native.Element_innerHTML && Native.Element_innerHTML.get) { - patch_innerHTML(Element.prototype, Native.Element_innerHTML); - } else if (Native.HTMLElement_innerHTML && Native.HTMLElement_innerHTML.get) { - patch_innerHTML(HTMLElement.prototype, Native.HTMLElement_innerHTML); + if (Env.Element.innerHTML && Env.Element.innerHTML.get) { + patch_innerHTML(Element.prototype, Env.Element.innerHTML); + } else if (Env.HTMLElement.innerHTML && Env.HTMLElement.innerHTML.get) { + patch_innerHTML(HTMLElement.prototype, Env.HTMLElement.innerHTML); } else { + // In this case, `innerHTML` has no exposed getter but still exists. Rather + // than using the environment proxy, we have to get and set it directly. /** @type {HTMLDivElement} */ - const rawDiv = Native.Document_createElement.call(document, 'div'); + const rawDiv = EnvProxy.createElement(document, 'div'); internals.addPatch(function(element) { patch_innerHTML(element, { @@ -91,7 +94,7 @@ export default function(internals) { // of the element and returning the resulting element's `innerHTML`. // TODO: Is this too expensive? get: /** @this {Element} */ function() { - return Native.Node_cloneNode.call(this, true).innerHTML; + return EnvProxy.cloneNode(this, true).innerHTML; }, // Implements setting `innerHTML` by creating an unpatched element, // setting `innerHTML` of that element and replacing the target @@ -101,14 +104,17 @@ export default function(internals) { // We need to do this because `template.appendChild` does not // route into `template.content`. /** @type {!Node} */ - const content = this.localName === 'template' ? (/** @type {!HTMLTemplateElement} */ (this)).content : this; + const content = + (EnvProxy.localName(this) === 'template') + ? EnvProxy.content(/** @type {!HTMLTemplateElement} */ (this)) + : this; rawDiv.innerHTML = assignedValue; - while (content.childNodes.length > 0) { - Native.Node_removeChild.call(content, content.childNodes[0]); + while (EnvProxy.childNodes(content).length > 0) { + EnvProxy.removeChild(content, content.childNodes[0]); } - while (rawDiv.childNodes.length > 0) { - Native.Node_appendChild.call(content, rawDiv.childNodes[0]); + while (EnvProxy.childNodes(rawDiv).length > 0) { + EnvProxy.appendChild(content, rawDiv.childNodes[0]); } }, }); @@ -125,12 +131,12 @@ export default function(internals) { function(name, newValue) { // Fast path for non-custom elements. if (this.__CE_state !== CEState.custom) { - return Native.Element_setAttribute.call(this, name, newValue); + return EnvProxy.setAttribute(this, name, newValue); } - const oldValue = Native.Element_getAttribute.call(this, name); - Native.Element_setAttribute.call(this, name, newValue); - newValue = Native.Element_getAttribute.call(this, name); + const oldValue = EnvProxy.getAttribute(this, name); + EnvProxy.setAttribute(this, name, newValue); + newValue = EnvProxy.getAttribute(this, name); internals.attributeChangedCallback(this, name, oldValue, newValue, null); }); @@ -144,12 +150,12 @@ export default function(internals) { function(namespace, name, newValue) { // Fast path for non-custom elements. if (this.__CE_state !== CEState.custom) { - return Native.Element_setAttributeNS.call(this, namespace, name, newValue); + return EnvProxy.setAttributeNS(this, namespace, name, newValue); } - const oldValue = Native.Element_getAttributeNS.call(this, namespace, name); - Native.Element_setAttributeNS.call(this, namespace, name, newValue); - newValue = Native.Element_getAttributeNS.call(this, namespace, name); + const oldValue = EnvProxy.getAttributeNS(this, namespace, name); + EnvProxy.setAttributeNS(this, namespace, name, newValue); + newValue = EnvProxy.getAttributeNS(this, namespace, name); internals.attributeChangedCallback(this, name, oldValue, newValue, namespace); }); @@ -161,11 +167,11 @@ export default function(internals) { function(name) { // Fast path for non-custom elements. if (this.__CE_state !== CEState.custom) { - return Native.Element_removeAttribute.call(this, name); + return EnvProxy.removeAttribute(this, name); } - const oldValue = Native.Element_getAttribute.call(this, name); - Native.Element_removeAttribute.call(this, name); + const oldValue = EnvProxy.getAttribute(this, name); + EnvProxy.removeAttribute(this, name); if (oldValue !== null) { internals.attributeChangedCallback(this, name, oldValue, null, null); } @@ -180,15 +186,15 @@ export default function(internals) { function(namespace, name) { // Fast path for non-custom elements. if (this.__CE_state !== CEState.custom) { - return Native.Element_removeAttributeNS.call(this, namespace, name); + return EnvProxy.removeAttributeNS(this, namespace, name); } - const oldValue = Native.Element_getAttributeNS.call(this, namespace, name); - Native.Element_removeAttributeNS.call(this, namespace, name); + const oldValue = EnvProxy.getAttributeNS(this, namespace, name); + EnvProxy.removeAttributeNS(this, namespace, name); // In older browsers, `Element#getAttributeNS` may return the empty string // instead of null if the attribute does not exist. For details, see; // https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttributeNS#Notes - const newValue = Native.Element_getAttributeNS.call(this, namespace, name); + const newValue = EnvProxy.getAttributeNS(this, namespace, name); if (oldValue !== newValue) { internals.attributeChangedCallback(this, name, oldValue, newValue, namespace); } @@ -219,24 +225,24 @@ export default function(internals) { }); } - if (Native.HTMLElement_insertAdjacentElement) { - patch_insertAdjacentElement(HTMLElement.prototype, Native.HTMLElement_insertAdjacentElement); - } else if (Native.Element_insertAdjacentElement) { - patch_insertAdjacentElement(Element.prototype, Native.Element_insertAdjacentElement); + if (Env.HTMLElement['insertAdjacentElement'] && Env.HTMLElement['insertAdjacentElement'].value) { + patch_insertAdjacentElement(HTMLElement.prototype, Env.HTMLElement['insertAdjacentElement'].value); + } else if (Env.Element['insertAdjacentElement'] && Env.Element['insertAdjacentElement'].value) { + patch_insertAdjacentElement(Element.prototype, Env.Element['insertAdjacentElement'].value); } else { console.warn('Custom Elements: `Element#insertAdjacentElement` was not patched.'); } PatchParentNode(internals, Element.prototype, { - prepend: Native.Element_prepend, - append: Native.Element_append, + prepend: (Env.Element.prepend || {}).value, + append: (Env.Element.append || {}).value, }); PatchChildNode(internals, Element.prototype, { - before: Native.Element_before, - after: Native.Element_after, - replaceWith: Native.Element_replaceWith, - remove: Native.Element_remove, + before: (Env.Element.before || {}).value, + after: (Env.Element.after || {}).value, + replaceWith: (Env.Element.replaceWith || {}).value, + remove: (Env.Element.remove || {}).value, }); }; diff --git a/src/Patch/Native.js b/src/Patch/Native.js index ce47975..4bdd5c6 100644 --- a/src/Patch/Native.js +++ b/src/Patch/Native.js @@ -6,28 +6,28 @@ export default { Document_importNode: Env.Document.importNode.value, Document_prepend: (Env.Document.prepend || {}).value, Document_append: (Env.Document.append || {}).value, - Node_cloneNode: window.Node.prototype.cloneNode, + Node_cloneNode: Env.Node.cloneNode.value, Node_appendChild: window.Node.prototype.appendChild, Node_insertBefore: window.Node.prototype.insertBefore, Node_removeChild: window.Node.prototype.removeChild, Node_replaceChild: window.Node.prototype.replaceChild, Node_textContent: Object.getOwnPropertyDescriptor(window.Node.prototype, 'textContent'), - Element_attachShadow: window.Element.prototype['attachShadow'], - Element_innerHTML: Object.getOwnPropertyDescriptor(window.Element.prototype, 'innerHTML'), - Element_getAttribute: window.Element.prototype.getAttribute, - Element_setAttribute: window.Element.prototype.setAttribute, - Element_removeAttribute: window.Element.prototype.removeAttribute, - Element_getAttributeNS: window.Element.prototype.getAttributeNS, - Element_setAttributeNS: window.Element.prototype.setAttributeNS, - Element_removeAttributeNS: window.Element.prototype.removeAttributeNS, - Element_insertAdjacentElement: window.Element.prototype['insertAdjacentElement'], - Element_prepend: window.Element.prototype['prepend'], - Element_append: window.Element.prototype['append'], - Element_before: window.Element.prototype['before'], - Element_after: window.Element.prototype['after'], - Element_replaceWith: window.Element.prototype['replaceWith'], - Element_remove: window.Element.prototype['remove'], + Element_attachShadow: (Env.Element.attachShadow || {}).value, + Element_innerHTML: Env.Element.innerHTML, + Element_getAttribute: Env.Element.getAttribute, + Element_setAttribute: Env.Element.setAttribute, + Element_removeAttribute: Env.Element.removeAttribute, + Element_getAttributeNS: Env.Element.getAttributeNS, + Element_setAttributeNS: Env.Element.setAttributeNS, + Element_removeAttributeNS: Env.Element.removeAttributeNS, + Element_insertAdjacentElement: Env.Element['insertAdjacentElement'], + Element_prepend: Env.Element['prepend'], + Element_append: Env.Element['append'], + Element_before: Env.Element['before'], + Element_after: Env.Element['after'], + Element_replaceWith: Env.Element['replaceWith'], + Element_remove: Env.Element['remove'], HTMLElement: window.HTMLElement, - HTMLElement_innerHTML: Object.getOwnPropertyDescriptor(window.HTMLElement.prototype, 'innerHTML'), - HTMLElement_insertAdjacentElement: window.HTMLElement.prototype['insertAdjacentElement'], + HTMLElement_innerHTML: Env.HTMLElement.innerHTML, + HTMLElement_insertAdjacentElement: Env.HTMLElement['insertAdjacentElement'], }; From 7f8c9ff72b0116a18421edbe4e2f06b6910bf6c6 Mon Sep 17 00:00:00 2001 From: Russell Bicknell Date: Fri, 9 Jun 2017 16:00:45 -0700 Subject: [PATCH 04/92] HTMLElement: replace 'Native.js' use with 'Environment.js'. --- src/Patch/HTMLElement.js | 7 ++++--- src/Patch/Native.js | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Patch/HTMLElement.js b/src/Patch/HTMLElement.js index f69c01a..7e53056 100644 --- a/src/Patch/HTMLElement.js +++ b/src/Patch/HTMLElement.js @@ -1,4 +1,5 @@ -import Native from './Native.js'; +import * as Env from '../Environment.js'; +import * as EnvProxy from '../EnvironmentProxy.js'; import CustomElementInternals from '../CustomElementInternals.js'; import CEState from '../CustomElementState.js'; import AlreadyConstructedMarker from '../AlreadyConstructedMarker.js'; @@ -26,7 +27,7 @@ export default function(internals) { const constructionStack = definition.constructionStack; if (constructionStack.length === 0) { - const element = Native.Document_createElement.call(document, definition.localName); + const element = EnvProxy.createElement(document, definition.localName); Object.setPrototypeOf(element, constructor.prototype); element.__CE_state = CEState.custom; element.__CE_definition = definition; @@ -47,7 +48,7 @@ export default function(internals) { return element; } - HTMLElement.prototype = Native.HTMLElement.prototype; + HTMLElement.prototype = Env.HTMLElement.constructor.value.prototype; return HTMLElement; })(); diff --git a/src/Patch/Native.js b/src/Patch/Native.js index 4bdd5c6..a6851e7 100644 --- a/src/Patch/Native.js +++ b/src/Patch/Native.js @@ -27,7 +27,7 @@ export default { Element_after: Env.Element['after'], Element_replaceWith: Env.Element['replaceWith'], Element_remove: Env.Element['remove'], - HTMLElement: window.HTMLElement, + HTMLElement: Env.HTMLElement, HTMLElement_innerHTML: Env.HTMLElement.innerHTML, HTMLElement_insertAdjacentElement: Env.HTMLElement['insertAdjacentElement'], }; From 512a9620033d1a8b8c675da86c8a438624d883cf Mon Sep 17 00:00:00 2001 From: Russell Bicknell Date: Fri, 9 Jun 2017 16:16:13 -0700 Subject: [PATCH 05/92] Node: replace 'Native.js' use with 'Environment.js'. --- src/EnvironmentProxy.js | 9 +++++++++ src/Patch/Native.js | 10 ++++----- src/Patch/Node.js | 45 ++++++++++++++++++++++------------------- 3 files changed, 38 insertions(+), 26 deletions(-) diff --git a/src/EnvironmentProxy.js b/src/EnvironmentProxy.js index 12f63fa..9816d35 100644 --- a/src/EnvironmentProxy.js +++ b/src/EnvironmentProxy.js @@ -11,6 +11,9 @@ export const createElement = (doc, localName) => createElementMethod.call(doc, l const createElementNSMethod = method(Env.Document.createElementNS); export const createElementNS = (doc, namespace, qualifiedName) => createElementNSMethod.call(doc, namespace, qualifiedName); +const createTextNodeMethod = method(Env.Document.createTextNode); +export const createTextNode = (doc, localName) => createTextNodeMethod.call(doc, localName); + const importNodeMethod = method(Env.Document.importNode); export const importNode = (doc, node, deep) => importNodeMethod.call(doc, node, deep); @@ -80,6 +83,9 @@ export const cloneNode = (node, deep) => cloneNodeMethod.call(node, deep); const firstChildGetter = getter(Env.Node.firstChild); export const firstChild = node => firstChildGetter.call(node); +const insertBeforeMethod = method(Env.Node.insertBefore); +export const insertBefore = (node, newChild, refChild) => insertBeforeMethod.call(node, newChild, refChild); + const isConnectedGetter = getter(Env.Node.isConnected); export const isConnected = node => isConnectedGetter.call(node); @@ -94,3 +100,6 @@ export const parentNode = node => parentNodeGetter.call(node); const removeChildMethod = method(Env.Node.removeChild); export const removeChild = (node, deep) => removeChildMethod.call(node, deep); + +const replaceChildMethod = method(Env.Node.replaceChild); +export const replaceChild = (node, newChild, oldChild) => replaceChildMethod.call(node, newChild, oldChild); diff --git a/src/Patch/Native.js b/src/Patch/Native.js index a6851e7..b11776f 100644 --- a/src/Patch/Native.js +++ b/src/Patch/Native.js @@ -7,11 +7,11 @@ export default { Document_prepend: (Env.Document.prepend || {}).value, Document_append: (Env.Document.append || {}).value, Node_cloneNode: Env.Node.cloneNode.value, - Node_appendChild: window.Node.prototype.appendChild, - Node_insertBefore: window.Node.prototype.insertBefore, - Node_removeChild: window.Node.prototype.removeChild, - Node_replaceChild: window.Node.prototype.replaceChild, - Node_textContent: Object.getOwnPropertyDescriptor(window.Node.prototype, 'textContent'), + Node_appendChild: Env.Node.appendChild.value, + Node_insertBefore: Env.Node.insertBefore.value, + Node_removeChild: Env.Node.removeChild.value, + Node_replaceChild: Env.Node.replaceChild.value, + Node_textContent: Env.Node.textContent, Element_attachShadow: (Env.Element.attachShadow || {}).value, Element_innerHTML: Env.Element.innerHTML, Element_getAttribute: Env.Element.getAttribute, diff --git a/src/Patch/Node.js b/src/Patch/Node.js index 98c3c2d..fe0b1e8 100644 --- a/src/Patch/Node.js +++ b/src/Patch/Node.js @@ -1,4 +1,5 @@ -import Native from './Native.js'; +import * as Env from '../Environment.js'; +import * as EnvProxy from '../EnvironmentProxy.js'; import CustomElementInternals from '../CustomElementInternals.js'; import * as Utilities from '../Utilities.js'; @@ -18,8 +19,8 @@ export default function(internals) { */ function(node, refNode) { if (node instanceof DocumentFragment) { - const insertedNodes = Array.prototype.slice.apply(node.childNodes); - const nativeResult = Native.Node_insertBefore.call(this, node, refNode); + const insertedNodes = Array.prototype.slice.apply(EnvProxy.childNodes(node)); + const nativeResult = EnvProxy.insertBefore(this, node, refNode); // DocumentFragments can't be connected, so `disconnectTree` will never // need to be called on a DocumentFragment's children after inserting it. @@ -34,7 +35,7 @@ export default function(internals) { } const nodeWasConnected = Utilities.isConnected(node); - const nativeResult = Native.Node_insertBefore.call(this, node, refNode); + const nativeResult = EnvProxy.insertBefore(this, node, refNode); if (nodeWasConnected) { internals.disconnectTree(node); @@ -55,8 +56,8 @@ export default function(internals) { */ function(node) { if (node instanceof DocumentFragment) { - const insertedNodes = Array.prototype.slice.apply(node.childNodes); - const nativeResult = Native.Node_appendChild.call(this, node); + const insertedNodes = Array.prototype.slice.apply(EnvProxy.childNodes(node)); + const nativeResult = EnvProxy.appendChild(this, node); // DocumentFragments can't be connected, so `disconnectTree` will never // need to be called on a DocumentFragment's children after inserting it. @@ -71,7 +72,7 @@ export default function(internals) { } const nodeWasConnected = Utilities.isConnected(node); - const nativeResult = Native.Node_appendChild.call(this, node); + const nativeResult = EnvProxy.appendChild(this, node); if (nodeWasConnected) { internals.disconnectTree(node); @@ -91,7 +92,7 @@ export default function(internals) { * @return {!Node} */ function(deep) { - const clone = Native.Node_cloneNode.call(this, deep); + const clone = EnvProxy.cloneNode(this, deep); // Only create custom elements if this element's owner document is // associated with the registry. if (!this.ownerDocument.__CE_hasRegistry) { @@ -110,7 +111,7 @@ export default function(internals) { */ function(node) { const nodeWasConnected = Utilities.isConnected(node); - const nativeResult = Native.Node_removeChild.call(this, node); + const nativeResult = EnvProxy.removeChild(this, node); if (nodeWasConnected) { internals.disconnectTree(node); @@ -128,8 +129,8 @@ export default function(internals) { */ function(nodeToInsert, nodeToRemove) { if (nodeToInsert instanceof DocumentFragment) { - const insertedNodes = Array.prototype.slice.apply(nodeToInsert.childNodes); - const nativeResult = Native.Node_replaceChild.call(this, nodeToInsert, nodeToRemove); + const insertedNodes = Array.prototype.slice.apply(EnvProxy.childNodes(nodeToInsert)); + const nativeResult = EnvProxy.replaceChild(this, nodeToInsert, nodeToRemove); // DocumentFragments can't be connected, so `disconnectTree` will never // need to be called on a DocumentFragment's children after inserting it. @@ -145,7 +146,7 @@ export default function(internals) { } const nodeToInsertWasConnected = Utilities.isConnected(nodeToInsert); - const nativeResult = Native.Node_replaceChild.call(this, nodeToInsert, nodeToRemove); + const nativeResult = EnvProxy.replaceChild(this, nodeToInsert, nodeToRemove); const thisIsConnected = Utilities.isConnected(this); if (thisIsConnected) { @@ -179,10 +180,10 @@ export default function(internals) { let removedNodes = undefined; // Checking for `firstChild` is faster than reading `childNodes.length` // to compare with 0. - if (this.firstChild) { + if (EnvProxy.firstChild(this)) { // Using `childNodes` is faster than `children`, even though we only // care about elements. - const childNodes = this.childNodes; + const childNodes = EnvProxy.childNodes(this); const childNodesLength = childNodes.length; if (childNodesLength > 0 && Utilities.isConnected(this)) { // Copying an array by iterating is faster than using slice. @@ -204,8 +205,8 @@ export default function(internals) { }); } - if (Native.Node_textContent && Native.Node_textContent.get) { - patch_textContent(Node.prototype, Native.Node_textContent); + if (Env.Node.textContent && Env.Node.textContent.get) { + patch_textContent(Node.prototype, Env.Node.textContent); } else { internals.addPatch(function(element) { patch_textContent(element, { @@ -217,17 +218,19 @@ export default function(internals) { /** @type {!Array} */ const parts = []; - for (let i = 0; i < this.childNodes.length; i++) { - parts.push(this.childNodes[i].textContent); + const childNodes = EnvProxy.childNodes(this); + for (let i = 0; i < childNodes.length; i++) { + parts.push(childNodes[i].textContent); } return parts.join(''); }, set: /** @this {Node} */ function(assignedValue) { - while (this.firstChild) { - Native.Node_removeChild.call(this, this.firstChild); + let child; + while (child = EnvProxy.firstChild(this)) { + EnvProxy.removeChild(this, child); } - Native.Node_appendChild.call(this, document.createTextNode(assignedValue)); + EnvProxy.appendChild(this, EnvProxy.createTextNode(document, assignedValue)); }, }); }); From 8a4e21cbf1016f6d423ef29dba588d9f68264d9a Mon Sep 17 00:00:00 2001 From: Russell Bicknell Date: Fri, 9 Jun 2017 16:22:20 -0700 Subject: [PATCH 06/92] Remove 'Native.js'. --- src/Patch/Native.js | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 src/Patch/Native.js diff --git a/src/Patch/Native.js b/src/Patch/Native.js deleted file mode 100644 index b11776f..0000000 --- a/src/Patch/Native.js +++ /dev/null @@ -1,33 +0,0 @@ -import * as Env from '../Environment.js'; - -export default { - Document_createElement: Env.Document.createElement.value, - Document_createElementNS: Env.Document.createElementNS.value, - Document_importNode: Env.Document.importNode.value, - Document_prepend: (Env.Document.prepend || {}).value, - Document_append: (Env.Document.append || {}).value, - Node_cloneNode: Env.Node.cloneNode.value, - Node_appendChild: Env.Node.appendChild.value, - Node_insertBefore: Env.Node.insertBefore.value, - Node_removeChild: Env.Node.removeChild.value, - Node_replaceChild: Env.Node.replaceChild.value, - Node_textContent: Env.Node.textContent, - Element_attachShadow: (Env.Element.attachShadow || {}).value, - Element_innerHTML: Env.Element.innerHTML, - Element_getAttribute: Env.Element.getAttribute, - Element_setAttribute: Env.Element.setAttribute, - Element_removeAttribute: Env.Element.removeAttribute, - Element_getAttributeNS: Env.Element.getAttributeNS, - Element_setAttributeNS: Env.Element.setAttributeNS, - Element_removeAttributeNS: Env.Element.removeAttributeNS, - Element_insertAdjacentElement: Env.Element['insertAdjacentElement'], - Element_prepend: Env.Element['prepend'], - Element_append: Env.Element['append'], - Element_before: Env.Element['before'], - Element_after: Env.Element['after'], - Element_replaceWith: Env.Element['replaceWith'], - Element_remove: Env.Element['remove'], - HTMLElement: Env.HTMLElement, - HTMLElement_innerHTML: Env.HTMLElement.innerHTML, - HTMLElement_insertAdjacentElement: Env.HTMLElement['insertAdjacentElement'], -}; From 67d40a1ed9be19642aae1def422861ef8ab60a5e Mon Sep 17 00:00:00 2001 From: Russell Bicknell Date: Fri, 9 Jun 2017 16:30:17 -0700 Subject: [PATCH 07/92] Fix a few typos causing Closure warnings. --- src/EnvironmentProxy.js | 2 +- src/Patch/Document.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/EnvironmentProxy.js b/src/EnvironmentProxy.js index 9816d35..078ad52 100644 --- a/src/EnvironmentProxy.js +++ b/src/EnvironmentProxy.js @@ -29,7 +29,7 @@ const getAttributeMethod = method(Env.Element.getAttribute); export const getAttribute = (node, name) => getAttributeMethod.call(node, name); const getAttributeNSMethod = method(Env.Element.getAttributeNS); -export const getAttributeNS = (node, ns, name, value) => getAttributeNSMethod.call(node, ns, name, value); +export const getAttributeNS = (node, ns, name) => getAttributeNSMethod.call(node, ns, name); const localNameGetter = getter(Env.Element.localName); export const localName = node => localNameGetter.call(node); diff --git a/src/Patch/Document.js b/src/Patch/Document.js index 28cedc3..990bc66 100644 --- a/src/Patch/Document.js +++ b/src/Patch/Document.js @@ -25,7 +25,7 @@ export default function(internals) { } const result = /** @type {!Element} */ - EnvProxy.createElement(this, localName); + (EnvProxy.createElement(this, localName)); internals.patch(result); return result; }); @@ -67,7 +67,7 @@ export default function(internals) { } const result = /** @type {!Element} */ - EnvProxy.createElementNS(this, namespace, localName); + (EnvProxy.createElementNS(this, namespace, localName)); internals.patch(result); return result; }); From 8c7a5248be15135a4a730526b0e1822ee3db3af7 Mon Sep 17 00:00:00 2001 From: Russell Bicknell Date: Fri, 9 Jun 2017 17:52:36 -0700 Subject: [PATCH 08/92] build --- custom-elements.min.js | 50 +++++++++++++++++++------------------- custom-elements.min.js.map | 2 +- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/custom-elements.min.js b/custom-elements.min.js index 0747489..95429c3 100644 --- a/custom-elements.min.js +++ b/custom-elements.min.js @@ -1,28 +1,28 @@ (function(){ -'use strict';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,e){e=e?e:new Set;for(var c=b;c;){if(c.nodeType===Node.ELEMENT_NODE){var d=c;a(d);var h=d.localName;if("link"===h&&"import"===d.getAttribute("rel")){c=d.import;if(c instanceof Node&&!e.has(c))for(e.add(c),c=c.firstChild;c;c=c.nextSibling)n(c,a,e);c=m(b,d);continue}else if("template"===h){c=m(b,d);continue}if(d=d.__CE_shadowRoot)for(d=d.firstChild;d;d=d.nextSibling)n(d,a,e)}c=c.firstChild?c.firstChild:m(b,c)}}function q(b,a,e){b[a]=e};function r(){this.a=new Map;this.m=new Map;this.f=[];this.b=!1}function ba(b,a,e){b.a.set(a,e);b.m.set(e.constructor,e)}function t(b,a){b.b=!0;b.f.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 e=0;e=} visitedImports\n */\nexport function walkDeepDescendantElements(root, callback, visitedImports = new Set()) {\n let node = root;\n while (node) {\n if (node.nodeType === Node.ELEMENT_NODE) {\n const element = /** @type {!Element} */(node);\n\n callback(element);\n\n const localName = element.localName;\n if (localName === 'link' && element.getAttribute('rel') === 'import') {\n // If this import (polyfilled or not) has it's root node available,\n // walk it.\n const importNode = /** @type {!Node} */ (element.import);\n if (importNode instanceof Node && !visitedImports.has(importNode)) {\n // Prevent multiple walks of the same import root.\n visitedImports.add(importNode);\n\n for (let child = importNode.firstChild; child; child = child.nextSibling) {\n walkDeepDescendantElements(child, callback, visitedImports);\n }\n }\n\n // Ignore descendants of import links to prevent attempting to walk the\n // elements created by the HTML Imports polyfill that we just walked\n // above.\n node = nextSiblingOrAncestorSibling(root, element);\n continue;\n } else if (localName === 'template') {\n // Ignore descendants of templates. There shouldn't be any descendants\n // because they will be moved into `.content` during construction in\n // browsers that support template but, in case they exist and are still\n // waiting to be moved by a polyfill, they will be ignored.\n node = nextSiblingOrAncestorSibling(root, element);\n continue;\n }\n\n // Walk shadow roots.\n const shadowRoot = element.__CE_shadowRoot;\n if (shadowRoot) {\n for (let child = shadowRoot.firstChild; child; child = child.nextSibling) {\n walkDeepDescendantElements(child, callback, visitedImports);\n }\n }\n }\n\n node = nextNode(root, node);\n }\n}\n\n/**\n * Used to suppress Closure's \"Modifying the prototype is only allowed if the\n * constructor is in the same scope\" warning without using\n * `@suppress {newCheckTypes, duplicate}` because `newCheckTypes` is too broad.\n *\n * @param {!Object} destination\n * @param {string} name\n * @param {*} value\n */\nexport function setPropertyUnchecked(destination, name, value) {\n destination[name] = value;\n}\n","import * as Utilities from './Utilities.js';\nimport CEState from './CustomElementState.js';\n\nexport default class CustomElementInternals {\n constructor() {\n /** @type {!Map} */\n this._localNameToDefinition = new Map();\n\n /** @type {!Map} */\n this._constructorToDefinition = new Map();\n\n /** @type {!Array} */\n this._patches = [];\n\n /** @type {boolean} */\n this._hasPatches = false;\n }\n\n /**\n * @param {string} localName\n * @param {!CustomElementDefinition} definition\n */\n setDefinition(localName, definition) {\n this._localNameToDefinition.set(localName, definition);\n this._constructorToDefinition.set(definition.constructor, definition);\n }\n\n /**\n * @param {string} localName\n * @return {!CustomElementDefinition|undefined}\n */\n localNameToDefinition(localName) {\n return this._localNameToDefinition.get(localName);\n }\n\n /**\n * @param {!Function} constructor\n * @return {!CustomElementDefinition|undefined}\n */\n constructorToDefinition(constructor) {\n return this._constructorToDefinition.get(constructor);\n }\n\n /**\n * @param {!function(!Node)} listener\n */\n addPatch(listener) {\n this._hasPatches = true;\n this._patches.push(listener);\n }\n\n /**\n * @param {!Node} node\n */\n patchTree(node) {\n if (!this._hasPatches) return;\n\n Utilities.walkDeepDescendantElements(node, element => this.patch(element));\n }\n\n /**\n * @param {!Node} node\n */\n patch(node) {\n if (!this._hasPatches) return;\n\n if (node.__CE_patched) return;\n node.__CE_patched = true;\n\n for (let i = 0; i < this._patches.length; i++) {\n this._patches[i](node);\n }\n }\n\n /**\n * @param {!Node} root\n */\n connectTree(root) {\n const elements = [];\n\n Utilities.walkDeepDescendantElements(root, element => elements.push(element));\n\n for (let i = 0; i < elements.length; i++) {\n const element = elements[i];\n if (element.__CE_state === CEState.custom) {\n this.connectedCallback(element);\n } else {\n this.upgradeElement(element);\n }\n }\n }\n\n /**\n * @param {!Node} root\n */\n disconnectTree(root) {\n const elements = [];\n\n Utilities.walkDeepDescendantElements(root, element => elements.push(element));\n\n for (let i = 0; i < elements.length; i++) {\n const element = elements[i];\n if (element.__CE_state === CEState.custom) {\n this.disconnectedCallback(element);\n }\n }\n }\n\n /**\n * Upgrades all uncustomized custom elements at and below a root node for\n * which there is a definition. When custom element reaction callbacks are\n * assumed to be called synchronously (which, by the current DOM / HTML spec\n * definitions, they are *not*), callbacks for both elements customized\n * synchronously by the parser and elements being upgraded occur in the same\n * relative order.\n *\n * NOTE: This function, when used to simulate the construction of a tree that\n * is already created but not customized (i.e. by the parser), does *not*\n * prevent the element from reading the 'final' (true) state of the tree. For\n * example, the element, during truly synchronous parsing / construction would\n * see that it contains no children as they have not yet been inserted.\n * However, this function does not modify the tree, the element will\n * (incorrectly) have children. Additionally, self-modification restrictions\n * for custom element constructors imposed by the DOM spec are *not* enforced.\n *\n *\n * The following nested list shows the steps extending down from the HTML\n * spec's parsing section that cause elements to be synchronously created and\n * upgraded:\n *\n * The \"in body\" insertion mode:\n * https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody\n * - Switch on token:\n * .. other cases ..\n * -> Any other start tag\n * - [Insert an HTML element](below) for the token.\n *\n * Insert an HTML element:\n * https://html.spec.whatwg.org/multipage/syntax.html#insert-an-html-element\n * - Insert a foreign element for the token in the HTML namespace:\n * https://html.spec.whatwg.org/multipage/syntax.html#insert-a-foreign-element\n * - Create an element for a token:\n * https://html.spec.whatwg.org/multipage/syntax.html#create-an-element-for-the-token\n * - Will execute script flag is true?\n * - (Element queue pushed to the custom element reactions stack.)\n * - Create an element:\n * https://dom.spec.whatwg.org/#concept-create-element\n * - Sync CE flag is true?\n * - Constructor called.\n * - Self-modification restrictions enforced.\n * - Sync CE flag is false?\n * - (Upgrade reaction enqueued.)\n * - Attributes appended to element.\n * (`attributeChangedCallback` reactions enqueued.)\n * - Will execute script flag is true?\n * - (Element queue popped from the custom element reactions stack.\n * Reactions in the popped stack are invoked.)\n * - (Element queue pushed to the custom element reactions stack.)\n * - Insert the element:\n * https://dom.spec.whatwg.org/#concept-node-insert\n * - Shadow-including descendants are connected. During parsing\n * construction, there are no shadow-*excluding* descendants.\n * However, the constructor may have validly attached a shadow\n * tree to itself and added descendants to that shadow tree.\n * (`connectedCallback` reactions enqueued.)\n * - (Element queue popped from the custom element reactions stack.\n * Reactions in the popped stack are invoked.)\n *\n * @param {!Node} root\n * @param {!Set=} visitedImports\n */\n patchAndUpgradeTree(root, visitedImports = new Set()) {\n const elements = [];\n\n const gatherElements = element => {\n if (element.localName === 'link' && element.getAttribute('rel') === 'import') {\n // The HTML Imports polyfill sets a descendant element of the link to\n // the `import` property, specifically this is *not* a Document.\n const importNode = /** @type {?Node} */ (element.import);\n\n if (importNode instanceof Node && importNode.readyState === 'complete') {\n importNode.__CE_isImportDocument = true;\n\n // Connected links are associated with the registry.\n importNode.__CE_hasRegistry = true;\n } else {\n // If this link's import root is not available, its contents can't be\n // walked. Wait for 'load' and walk it when it's ready.\n element.addEventListener('load', () => {\n const importNode = /** @type {!Node} */ (element.import);\n\n if (importNode.__CE_documentLoadHandled) return;\n importNode.__CE_documentLoadHandled = true;\n\n importNode.__CE_isImportDocument = true;\n\n // Connected links are associated with the registry.\n importNode.__CE_hasRegistry = true;\n\n // Clone the `visitedImports` set that was populated sync during\n // the `patchAndUpgradeTree` call that caused this 'load' handler to\n // be added. Then, remove *this* link's import node so that we can\n // walk that import again, even if it was partially walked later\n // during the same `patchAndUpgradeTree` call.\n const clonedVisitedImports = new Set(visitedImports);\n visitedImports.delete(importNode);\n\n this.patchAndUpgradeTree(importNode, visitedImports);\n });\n }\n } else {\n elements.push(element);\n }\n };\n\n // `walkDeepDescendantElements` populates (and internally checks against)\n // `visitedImports` when traversing a loaded import.\n Utilities.walkDeepDescendantElements(root, gatherElements, visitedImports);\n\n if (this._hasPatches) {\n for (let i = 0; i < elements.length; i++) {\n this.patch(elements[i]);\n }\n }\n\n for (let i = 0; i < elements.length; i++) {\n this.upgradeElement(elements[i]);\n }\n }\n\n /**\n * @param {!Element} element\n */\n upgradeElement(element) {\n const currentState = element.__CE_state;\n if (currentState !== undefined) return;\n\n const definition = this.localNameToDefinition(element.localName);\n if (!definition) return;\n\n definition.constructionStack.push(element);\n\n const constructor = definition.constructor;\n try {\n try {\n let result = new (constructor)();\n if (result !== element) {\n throw new Error('The custom element constructor did not produce the element being upgraded.');\n }\n } finally {\n definition.constructionStack.pop();\n }\n } catch (e) {\n element.__CE_state = CEState.failed;\n throw e;\n }\n\n element.__CE_state = CEState.custom;\n element.__CE_definition = definition;\n\n if (definition.attributeChangedCallback) {\n const observedAttributes = definition.observedAttributes;\n for (let i = 0; i < observedAttributes.length; i++) {\n const name = observedAttributes[i];\n const value = element.getAttribute(name);\n if (value !== null) {\n this.attributeChangedCallback(element, name, null, value, null);\n }\n }\n }\n\n if (Utilities.isConnected(element)) {\n this.connectedCallback(element);\n }\n }\n\n /**\n * @param {!Element} element\n */\n connectedCallback(element) {\n const definition = element.__CE_definition;\n if (definition.connectedCallback) {\n definition.connectedCallback.call(element);\n }\n }\n\n /**\n * @param {!Element} element\n */\n disconnectedCallback(element) {\n const definition = element.__CE_definition;\n if (definition.disconnectedCallback) {\n definition.disconnectedCallback.call(element);\n }\n }\n\n /**\n * @param {!Element} element\n * @param {string} name\n * @param {?string} oldValue\n * @param {?string} newValue\n * @param {?string} namespace\n */\n attributeChangedCallback(element, name, oldValue, newValue, namespace) {\n const definition = element.__CE_definition;\n if (\n definition.attributeChangedCallback &&\n definition.observedAttributes.indexOf(name) > -1\n ) {\n definition.attributeChangedCallback.call(element, name, oldValue, newValue, namespace);\n }\n }\n}\n","/**\n * @enum {number}\n */\nconst CustomElementState = {\n custom: 1,\n failed: 2,\n};\n\nexport default CustomElementState;\n","import CustomElementInternals from './CustomElementInternals.js';\n\nexport default class DocumentConstructionObserver {\n constructor(internals, doc) {\n /**\n * @type {!CustomElementInternals}\n */\n this._internals = internals;\n\n /**\n * @type {!Document}\n */\n this._document = doc;\n\n /**\n * @type {MutationObserver|undefined}\n */\n this._observer = undefined;\n\n\n // Simulate tree construction for all currently accessible nodes in the\n // document.\n this._internals.patchAndUpgradeTree(this._document);\n\n if (this._document.readyState === 'loading') {\n this._observer = new MutationObserver(this._handleMutations.bind(this));\n\n // Nodes created by the parser are given to the observer *before* the next\n // task runs. Inline scripts are run in a new task. This means that the\n // observer will be able to handle the newly parsed nodes before the inline\n // script is run.\n this._observer.observe(this._document, {\n childList: true,\n subtree: true,\n });\n }\n }\n\n disconnect() {\n if (this._observer) {\n this._observer.disconnect();\n }\n }\n\n /**\n * @param {!Array} mutations\n */\n _handleMutations(mutations) {\n // Once the document's `readyState` is 'interactive' or 'complete', all new\n // nodes created within that document will be the result of script and\n // should be handled by patching.\n const readyState = this._document.readyState;\n if (readyState === 'interactive' || readyState === 'complete') {\n this.disconnect();\n }\n\n for (let i = 0; i < mutations.length; i++) {\n const addedNodes = mutations[i].addedNodes;\n for (let j = 0; j < addedNodes.length; j++) {\n const node = addedNodes[j];\n this._internals.patchAndUpgradeTree(node);\n }\n }\n }\n}\n","/**\n * @template T\n */\nexport default class Deferred {\n constructor() {\n /**\n * @private\n * @type {T|undefined}\n */\n this._value = undefined;\n\n /**\n * @private\n * @type {Function|undefined}\n */\n this._resolve = undefined;\n\n /**\n * @private\n * @type {!Promise}\n */\n this._promise = new Promise(resolve => {\n this._resolve = resolve;\n\n if (this._value) {\n resolve(this._value);\n }\n });\n }\n\n /**\n * @param {T} value\n */\n resolve(value) {\n if (this._value) {\n throw new Error('Already resolved.');\n }\n\n this._value = value;\n\n if (this._resolve) {\n this._resolve(value);\n }\n }\n\n /**\n * @return {!Promise}\n */\n toPromise() {\n return this._promise;\n }\n}\n","import CustomElementInternals from './CustomElementInternals.js';\nimport DocumentConstructionObserver from './DocumentConstructionObserver.js';\nimport Deferred from './Deferred.js';\nimport * as Utilities from './Utilities.js';\n\n/**\n * @unrestricted\n */\nexport default class CustomElementRegistry {\n\n /**\n * @param {!CustomElementInternals} internals\n */\n constructor(internals) {\n /**\n * @private\n * @type {boolean}\n */\n this._elementDefinitionIsRunning = false;\n\n /**\n * @private\n * @type {!CustomElementInternals}\n */\n this._internals = internals;\n\n /**\n * @private\n * @type {!Map>}\n */\n this._whenDefinedDeferred = new Map();\n\n /**\n * The default flush callback triggers the document walk synchronously.\n * @private\n * @type {!Function}\n */\n this._flushCallback = fn => fn();\n\n /**\n * @private\n * @type {boolean}\n */\n this._flushPending = false;\n\n /**\n * @private\n * @type {!Array}\n */\n this._unflushedLocalNames = [];\n\n /**\n * @private\n * @type {!DocumentConstructionObserver}\n */\n this._documentConstructionObserver = new DocumentConstructionObserver(internals, document);\n }\n\n /**\n * @param {string} localName\n * @param {!Function} constructor\n */\n define(localName, constructor) {\n if (!(constructor instanceof Function)) {\n throw new TypeError('Custom element constructors must be functions.');\n }\n\n if (!Utilities.isValidCustomElementName(localName)) {\n throw new SyntaxError(`The element name '${localName}' is not valid.`);\n }\n\n if (this._internals.localNameToDefinition(localName)) {\n throw new Error(`A custom element with name '${localName}' has already been defined.`);\n }\n\n if (this._elementDefinitionIsRunning) {\n throw new Error('A custom element is already being defined.');\n }\n this._elementDefinitionIsRunning = true;\n\n let connectedCallback;\n let disconnectedCallback;\n let adoptedCallback;\n let attributeChangedCallback;\n let observedAttributes;\n try {\n /** @type {!Object} */\n const prototype = constructor.prototype;\n if (!(prototype instanceof Object)) {\n throw new TypeError('The custom element constructor\\'s prototype is not an object.');\n }\n\n function getCallback(name) {\n const callbackValue = prototype[name];\n if (callbackValue !== undefined && !(callbackValue instanceof Function)) {\n throw new Error(`The '${name}' callback must be a function.`);\n }\n return callbackValue;\n }\n\n connectedCallback = getCallback('connectedCallback');\n disconnectedCallback = getCallback('disconnectedCallback');\n adoptedCallback = getCallback('adoptedCallback');\n attributeChangedCallback = getCallback('attributeChangedCallback');\n observedAttributes = constructor['observedAttributes'] || [];\n } catch (e) {\n return;\n } finally {\n this._elementDefinitionIsRunning = false;\n }\n\n const definition = {\n localName,\n constructor,\n connectedCallback,\n disconnectedCallback,\n adoptedCallback,\n attributeChangedCallback,\n observedAttributes,\n constructionStack: [],\n };\n\n this._internals.setDefinition(localName, definition);\n\n this._unflushedLocalNames.push(localName);\n\n // If we've already called the flush callback and it hasn't called back yet,\n // don't call it again.\n if (!this._flushPending) {\n this._flushPending = true;\n this._flushCallback(() => this._flush());\n }\n }\n\n _flush() {\n // If no new definitions were defined, don't attempt to flush. This could\n // happen if a flush callback keeps the function it is given and calls it\n // multiple times.\n if (this._flushPending === false) return;\n\n this._flushPending = false;\n this._internals.patchAndUpgradeTree(document);\n\n while (this._unflushedLocalNames.length > 0) {\n const localName = this._unflushedLocalNames.shift();\n const deferred = this._whenDefinedDeferred.get(localName);\n if (deferred) {\n deferred.resolve(undefined);\n }\n }\n }\n\n /**\n * @param {string} localName\n * @return {Function|undefined}\n */\n get(localName) {\n const definition = this._internals.localNameToDefinition(localName);\n if (definition) {\n return definition.constructor;\n }\n\n return undefined;\n }\n\n /**\n * @param {string} localName\n * @return {!Promise}\n */\n whenDefined(localName) {\n if (!Utilities.isValidCustomElementName(localName)) {\n return Promise.reject(new SyntaxError(`'${localName}' is not a valid custom element name.`));\n }\n\n const prior = this._whenDefinedDeferred.get(localName);\n if (prior) {\n return prior.toPromise();\n }\n\n const deferred = new Deferred();\n this._whenDefinedDeferred.set(localName, deferred);\n\n const definition = this._internals.localNameToDefinition(localName);\n // Resolve immediately only if the given local name has a definition *and*\n // the full document walk to upgrade elements with that local name has\n // already happened.\n if (definition && this._unflushedLocalNames.indexOf(localName) === -1) {\n deferred.resolve(undefined);\n }\n\n return deferred.toPromise();\n }\n\n polyfillWrapFlushCallback(outer) {\n this._documentConstructionObserver.disconnect();\n const inner = this._flushCallback;\n this._flushCallback = flush => outer(() => inner(flush));\n }\n}\n\n// Closure compiler exports.\nwindow['CustomElementRegistry'] = CustomElementRegistry;\nCustomElementRegistry.prototype['define'] = CustomElementRegistry.prototype.define;\nCustomElementRegistry.prototype['get'] = CustomElementRegistry.prototype.get;\nCustomElementRegistry.prototype['whenDefined'] = CustomElementRegistry.prototype.whenDefined;\nCustomElementRegistry.prototype['polyfillWrapFlushCallback'] = CustomElementRegistry.prototype.polyfillWrapFlushCallback;\n","export default {\n Document_createElement: window.Document.prototype.createElement,\n Document_createElementNS: window.Document.prototype.createElementNS,\n Document_importNode: window.Document.prototype.importNode,\n Document_prepend: window.Document.prototype['prepend'],\n Document_append: window.Document.prototype['append'],\n Node_cloneNode: window.Node.prototype.cloneNode,\n Node_appendChild: window.Node.prototype.appendChild,\n Node_insertBefore: window.Node.prototype.insertBefore,\n Node_removeChild: window.Node.prototype.removeChild,\n Node_replaceChild: window.Node.prototype.replaceChild,\n Node_textContent: Object.getOwnPropertyDescriptor(window.Node.prototype, 'textContent'),\n Element_attachShadow: window.Element.prototype['attachShadow'],\n Element_innerHTML: Object.getOwnPropertyDescriptor(window.Element.prototype, 'innerHTML'),\n Element_getAttribute: window.Element.prototype.getAttribute,\n Element_setAttribute: window.Element.prototype.setAttribute,\n Element_removeAttribute: window.Element.prototype.removeAttribute,\n Element_getAttributeNS: window.Element.prototype.getAttributeNS,\n Element_setAttributeNS: window.Element.prototype.setAttributeNS,\n Element_removeAttributeNS: window.Element.prototype.removeAttributeNS,\n Element_insertAdjacentElement: window.Element.prototype['insertAdjacentElement'],\n Element_prepend: window.Element.prototype['prepend'],\n Element_append: window.Element.prototype['append'],\n Element_before: window.Element.prototype['before'],\n Element_after: window.Element.prototype['after'],\n Element_replaceWith: window.Element.prototype['replaceWith'],\n Element_remove: window.Element.prototype['remove'],\n HTMLElement: window.HTMLElement,\n HTMLElement_innerHTML: Object.getOwnPropertyDescriptor(window.HTMLElement.prototype, 'innerHTML'),\n HTMLElement_insertAdjacentElement: window.HTMLElement.prototype['insertAdjacentElement'],\n};\n","import Native from './Native.js';\nimport CustomElementInternals from '../CustomElementInternals.js';\nimport CEState from '../CustomElementState.js';\nimport AlreadyConstructedMarker from '../AlreadyConstructedMarker.js';\n\n/**\n * @param {!CustomElementInternals} internals\n */\nexport default function(internals) {\n window['HTMLElement'] = (function() {\n /**\n * @type {function(new: HTMLElement): !HTMLElement}\n */\n function HTMLElement() {\n // This should really be `new.target` but `new.target` can't be emulated\n // in ES5. Assuming the user keeps the default value of the constructor's\n // prototype's `constructor` property, this is equivalent.\n /** @type {!Function} */\n const constructor = this.constructor;\n\n const definition = internals.constructorToDefinition(constructor);\n if (!definition) {\n throw new Error('The custom element being constructed was not registered with `customElements`.');\n }\n\n const constructionStack = definition.constructionStack;\n\n if (constructionStack.length === 0) {\n const element = Native.Document_createElement.call(document, definition.localName);\n Object.setPrototypeOf(element, constructor.prototype);\n element.__CE_state = CEState.custom;\n element.__CE_definition = definition;\n internals.patch(element);\n return element;\n }\n\n const lastIndex = constructionStack.length - 1;\n const element = constructionStack[lastIndex];\n if (element === AlreadyConstructedMarker) {\n throw new Error('The HTMLElement constructor was either called reentrantly for this constructor or called multiple times.');\n }\n constructionStack[lastIndex] = AlreadyConstructedMarker;\n\n Object.setPrototypeOf(element, constructor.prototype);\n internals.patch(/** @type {!HTMLElement} */ (element));\n\n return element;\n }\n\n HTMLElement.prototype = Native.HTMLElement.prototype;\n\n return HTMLElement;\n })();\n};\n","/**\n * @license\n * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n */\n\nimport CustomElementInternals from './CustomElementInternals.js';\nimport CustomElementRegistry from './CustomElementRegistry.js';\n\nimport PatchHTMLElement from './Patch/HTMLElement.js';\nimport PatchDocument from './Patch/Document.js';\nimport PatchNode from './Patch/Node.js';\nimport PatchElement from './Patch/Element.js';\n\nconst priorCustomElements = window['customElements'];\n\nif (!priorCustomElements ||\n priorCustomElements['forcePolyfill'] ||\n (typeof priorCustomElements['define'] != 'function') ||\n (typeof priorCustomElements['get'] != 'function')) {\n /** @type {!CustomElementInternals} */\n const internals = new CustomElementInternals();\n\n PatchHTMLElement(internals);\n PatchDocument(internals);\n PatchNode(internals);\n PatchElement(internals);\n\n // The main document is always associated with the registry.\n document.__CE_hasRegistry = true;\n\n /** @type {!CustomElementRegistry} */\n const customElements = new CustomElementRegistry(internals);\n\n Object.defineProperty(window, 'customElements', {\n configurable: true,\n enumerable: true,\n value: customElements,\n });\n}\n","import CustomElementInternals from '../../CustomElementInternals.js';\nimport * as Utilities from '../../Utilities.js';\n\n/**\n * @typedef {{\n * prepend: !function(...(!Node|string)),\n * append: !function(...(!Node|string)),\n * }}\n */\nlet ParentNodeNativeMethods;\n\n/**\n * @param {!CustomElementInternals} internals\n * @param {!Object} destination\n * @param {!ParentNodeNativeMethods} builtIn\n */\nexport default function(internals, destination, builtIn) {\n /**\n * @param {...(!Node|string)} nodes\n */\n destination['prepend'] = function(...nodes) {\n // TODO: Fix this for when one of `nodes` is a DocumentFragment!\n const connectedBefore = /** @type {!Array} */ (nodes.filter(node => {\n // DocumentFragments are not connected and will not be added to the list.\n return node instanceof Node && Utilities.isConnected(node);\n }));\n\n builtIn.prepend.apply(this, nodes);\n\n for (let i = 0; i < connectedBefore.length; i++) {\n internals.disconnectTree(connectedBefore[i]);\n }\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node instanceof Element) {\n internals.connectTree(node);\n }\n }\n }\n };\n\n /**\n * @param {...(!Node|string)} nodes\n */\n destination['append'] = function(...nodes) {\n // TODO: Fix this for when one of `nodes` is a DocumentFragment!\n const connectedBefore = /** @type {!Array} */ (nodes.filter(node => {\n // DocumentFragments are not connected and will not be added to the list.\n return node instanceof Node && Utilities.isConnected(node);\n }));\n\n builtIn.append.apply(this, nodes);\n\n for (let i = 0; i < connectedBefore.length; i++) {\n internals.disconnectTree(connectedBefore[i]);\n }\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node instanceof Element) {\n internals.connectTree(node);\n }\n }\n }\n };\n};\n","import Native from './Native.js';\nimport CustomElementInternals from '../CustomElementInternals.js';\nimport * as Utilities from '../Utilities.js';\n\nimport PatchParentNode from './Interface/ParentNode.js';\n\n/**\n * @param {!CustomElementInternals} internals\n */\nexport default function(internals) {\n Utilities.setPropertyUnchecked(Document.prototype, 'createElement',\n /**\n * @this {Document}\n * @param {string} localName\n * @return {!Element}\n */\n function(localName) {\n // Only create custom elements if this document is associated with the registry.\n if (this.__CE_hasRegistry) {\n const definition = internals.localNameToDefinition(localName);\n if (definition) {\n return new (definition.constructor)();\n }\n }\n\n const result = /** @type {!Element} */\n (Native.Document_createElement.call(this, localName));\n internals.patch(result);\n return result;\n });\n\n Utilities.setPropertyUnchecked(Document.prototype, 'importNode',\n /**\n * @this {Document}\n * @param {!Node} node\n * @param {boolean=} deep\n * @return {!Node}\n */\n function(node, deep) {\n const clone = Native.Document_importNode.call(this, node, deep);\n // Only create custom elements if this document is associated with the registry.\n if (!this.__CE_hasRegistry) {\n internals.patchTree(clone);\n } else {\n internals.patchAndUpgradeTree(clone);\n }\n return clone;\n });\n\n const NS_HTML = \"http://www.w3.org/1999/xhtml\";\n\n Utilities.setPropertyUnchecked(Document.prototype, 'createElementNS',\n /**\n * @this {Document}\n * @param {?string} namespace\n * @param {string} localName\n * @return {!Element}\n */\n function(namespace, localName) {\n // Only create custom elements if this document is associated with the registry.\n if (this.__CE_hasRegistry && (namespace === null || namespace === NS_HTML)) {\n const definition = internals.localNameToDefinition(localName);\n if (definition) {\n return new (definition.constructor)();\n }\n }\n\n const result = /** @type {!Element} */\n (Native.Document_createElementNS.call(this, namespace, localName));\n internals.patch(result);\n return result;\n });\n\n PatchParentNode(internals, Document.prototype, {\n prepend: Native.Document_prepend,\n append: Native.Document_append,\n });\n};\n","import Native from './Native.js';\nimport CustomElementInternals from '../CustomElementInternals.js';\nimport * as Utilities from '../Utilities.js';\n\n/**\n * @param {!CustomElementInternals} internals\n */\nexport default function(internals) {\n // `Node#nodeValue` is implemented on `Attr`.\n // `Node#textContent` is implemented on `Attr`, `Element`.\n\n Utilities.setPropertyUnchecked(Node.prototype, 'insertBefore',\n /**\n * @this {Node}\n * @param {!Node} node\n * @param {?Node} refNode\n * @return {!Node}\n */\n function(node, refNode) {\n if (node instanceof DocumentFragment) {\n const insertedNodes = Array.prototype.slice.apply(node.childNodes);\n const nativeResult = Native.Node_insertBefore.call(this, node, refNode);\n\n // DocumentFragments can't be connected, so `disconnectTree` will never\n // need to be called on a DocumentFragment's children after inserting it.\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < insertedNodes.length; i++) {\n internals.connectTree(insertedNodes[i]);\n }\n }\n\n return nativeResult;\n }\n\n const nodeWasConnected = Utilities.isConnected(node);\n const nativeResult = Native.Node_insertBefore.call(this, node, refNode);\n\n if (nodeWasConnected) {\n internals.disconnectTree(node);\n }\n\n if (Utilities.isConnected(this)) {\n internals.connectTree(node);\n }\n\n return nativeResult;\n });\n\n Utilities.setPropertyUnchecked(Node.prototype, 'appendChild',\n /**\n * @this {Node}\n * @param {!Node} node\n * @return {!Node}\n */\n function(node) {\n if (node instanceof DocumentFragment) {\n const insertedNodes = Array.prototype.slice.apply(node.childNodes);\n const nativeResult = Native.Node_appendChild.call(this, node);\n\n // DocumentFragments can't be connected, so `disconnectTree` will never\n // need to be called on a DocumentFragment's children after inserting it.\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < insertedNodes.length; i++) {\n internals.connectTree(insertedNodes[i]);\n }\n }\n\n return nativeResult;\n }\n\n const nodeWasConnected = Utilities.isConnected(node);\n const nativeResult = Native.Node_appendChild.call(this, node);\n\n if (nodeWasConnected) {\n internals.disconnectTree(node);\n }\n\n if (Utilities.isConnected(this)) {\n internals.connectTree(node);\n }\n\n return nativeResult;\n });\n\n Utilities.setPropertyUnchecked(Node.prototype, 'cloneNode',\n /**\n * @this {Node}\n * @param {boolean=} deep\n * @return {!Node}\n */\n function(deep) {\n const clone = Native.Node_cloneNode.call(this, deep);\n // Only create custom elements if this element's owner document is\n // associated with the registry.\n if (!this.ownerDocument.__CE_hasRegistry) {\n internals.patchTree(clone);\n } else {\n internals.patchAndUpgradeTree(clone);\n }\n return clone;\n });\n\n Utilities.setPropertyUnchecked(Node.prototype, 'removeChild',\n /**\n * @this {Node}\n * @param {!Node} node\n * @return {!Node}\n */\n function(node) {\n const nodeWasConnected = Utilities.isConnected(node);\n const nativeResult = Native.Node_removeChild.call(this, node);\n\n if (nodeWasConnected) {\n internals.disconnectTree(node);\n }\n\n return nativeResult;\n });\n\n Utilities.setPropertyUnchecked(Node.prototype, 'replaceChild',\n /**\n * @this {Node}\n * @param {!Node} nodeToInsert\n * @param {!Node} nodeToRemove\n * @return {!Node}\n */\n function(nodeToInsert, nodeToRemove) {\n if (nodeToInsert instanceof DocumentFragment) {\n const insertedNodes = Array.prototype.slice.apply(nodeToInsert.childNodes);\n const nativeResult = Native.Node_replaceChild.call(this, nodeToInsert, nodeToRemove);\n\n // DocumentFragments can't be connected, so `disconnectTree` will never\n // need to be called on a DocumentFragment's children after inserting it.\n\n if (Utilities.isConnected(this)) {\n internals.disconnectTree(nodeToRemove);\n for (let i = 0; i < insertedNodes.length; i++) {\n internals.connectTree(insertedNodes[i]);\n }\n }\n\n return nativeResult;\n }\n\n const nodeToInsertWasConnected = Utilities.isConnected(nodeToInsert);\n const nativeResult = Native.Node_replaceChild.call(this, nodeToInsert, nodeToRemove);\n const thisIsConnected = Utilities.isConnected(this);\n\n if (thisIsConnected) {\n internals.disconnectTree(nodeToRemove);\n }\n\n if (nodeToInsertWasConnected) {\n internals.disconnectTree(nodeToInsert);\n }\n\n if (thisIsConnected) {\n internals.connectTree(nodeToInsert);\n }\n\n return nativeResult;\n });\n\n\n function patch_textContent(destination, baseDescriptor) {\n Object.defineProperty(destination, 'textContent', {\n enumerable: baseDescriptor.enumerable,\n configurable: true,\n get: baseDescriptor.get,\n set: /** @this {Node} */ function(assignedValue) {\n // If this is a text node then there are no nodes to disconnect.\n if (this.nodeType === Node.TEXT_NODE) {\n baseDescriptor.set.call(this, assignedValue);\n return;\n }\n\n let removedNodes = undefined;\n // Checking for `firstChild` is faster than reading `childNodes.length`\n // to compare with 0.\n if (this.firstChild) {\n // Using `childNodes` is faster than `children`, even though we only\n // care about elements.\n const childNodes = this.childNodes;\n const childNodesLength = childNodes.length;\n if (childNodesLength > 0 && Utilities.isConnected(this)) {\n // Copying an array by iterating is faster than using slice.\n removedNodes = new Array(childNodesLength);\n for (let i = 0; i < childNodesLength; i++) {\n removedNodes[i] = childNodes[i];\n }\n }\n }\n\n baseDescriptor.set.call(this, assignedValue);\n\n if (removedNodes) {\n for (let i = 0; i < removedNodes.length; i++) {\n internals.disconnectTree(removedNodes[i]);\n }\n }\n },\n });\n }\n\n if (Native.Node_textContent && Native.Node_textContent.get) {\n patch_textContent(Node.prototype, Native.Node_textContent);\n } else {\n internals.addPatch(function(element) {\n patch_textContent(element, {\n enumerable: true,\n configurable: true,\n // NOTE: This implementation of the `textContent` getter assumes that\n // text nodes' `textContent` getter will not be patched.\n get: /** @this {Node} */ function() {\n /** @type {!Array} */\n const parts = [];\n\n for (let i = 0; i < this.childNodes.length; i++) {\n parts.push(this.childNodes[i].textContent);\n }\n\n return parts.join('');\n },\n set: /** @this {Node} */ function(assignedValue) {\n while (this.firstChild) {\n Native.Node_removeChild.call(this, this.firstChild);\n }\n Native.Node_appendChild.call(this, document.createTextNode(assignedValue));\n },\n });\n });\n }\n};\n","import CustomElementInternals from '../../CustomElementInternals.js';\nimport * as Utilities from '../../Utilities.js';\n\n/**\n * @typedef {{\n * before: !function(...(!Node|string)),\n * after: !function(...(!Node|string)),\n * replaceWith: !function(...(!Node|string)),\n * remove: !function(),\n * }}\n */\nlet ChildNodeNativeMethods;\n\n/**\n * @param {!CustomElementInternals} internals\n * @param {!Object} destination\n * @param {!ChildNodeNativeMethods} builtIn\n */\nexport default function(internals, destination, builtIn) {\n /**\n * @param {...(!Node|string)} nodes\n */\n destination['before'] = function(...nodes) {\n // TODO: Fix this for when one of `nodes` is a DocumentFragment!\n const connectedBefore = /** @type {!Array} */ (nodes.filter(node => {\n // DocumentFragments are not connected and will not be added to the list.\n return node instanceof Node && Utilities.isConnected(node);\n }));\n\n builtIn.before.apply(this, nodes);\n\n for (let i = 0; i < connectedBefore.length; i++) {\n internals.disconnectTree(connectedBefore[i]);\n }\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node instanceof Element) {\n internals.connectTree(node);\n }\n }\n }\n };\n\n /**\n * @param {...(!Node|string)} nodes\n */\n destination['after'] = function(...nodes) {\n // TODO: Fix this for when one of `nodes` is a DocumentFragment!\n const connectedBefore = /** @type {!Array} */ (nodes.filter(node => {\n // DocumentFragments are not connected and will not be added to the list.\n return node instanceof Node && Utilities.isConnected(node);\n }));\n\n builtIn.after.apply(this, nodes);\n\n for (let i = 0; i < connectedBefore.length; i++) {\n internals.disconnectTree(connectedBefore[i]);\n }\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node instanceof Element) {\n internals.connectTree(node);\n }\n }\n }\n };\n\n /**\n * @param {...(!Node|string)} nodes\n */\n destination['replaceWith'] = function(...nodes) {\n // TODO: Fix this for when one of `nodes` is a DocumentFragment!\n const connectedBefore = /** @type {!Array} */ (nodes.filter(node => {\n // DocumentFragments are not connected and will not be added to the list.\n return node instanceof Node && Utilities.isConnected(node);\n }));\n\n const wasConnected = Utilities.isConnected(this);\n\n builtIn.replaceWith.apply(this, nodes);\n\n for (let i = 0; i < connectedBefore.length; i++) {\n internals.disconnectTree(connectedBefore[i]);\n }\n\n if (wasConnected) {\n internals.disconnectTree(this);\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node instanceof Element) {\n internals.connectTree(node);\n }\n }\n }\n };\n\n destination['remove'] = function() {\n const wasConnected = Utilities.isConnected(this);\n\n builtIn.remove.call(this);\n\n if (wasConnected) {\n internals.disconnectTree(this);\n }\n };\n};\n","import Native from './Native.js';\nimport CustomElementInternals from '../CustomElementInternals.js';\nimport CEState from '../CustomElementState.js';\nimport * as Utilities from '../Utilities.js';\n\nimport PatchParentNode from './Interface/ParentNode.js';\nimport PatchChildNode from './Interface/ChildNode.js';\n\n/**\n * @param {!CustomElementInternals} internals\n */\nexport default function(internals) {\n if (Native.Element_attachShadow) {\n Utilities.setPropertyUnchecked(Element.prototype, 'attachShadow',\n /**\n * @this {Element}\n * @param {!{mode: string}} init\n * @return {ShadowRoot}\n */\n function(init) {\n const shadowRoot = Native.Element_attachShadow.call(this, init);\n this.__CE_shadowRoot = shadowRoot;\n return shadowRoot;\n });\n } else {\n console.warn('Custom Elements: `Element#attachShadow` was not patched.');\n }\n\n\n function patch_innerHTML(destination, baseDescriptor) {\n Object.defineProperty(destination, 'innerHTML', {\n enumerable: baseDescriptor.enumerable,\n configurable: true,\n get: baseDescriptor.get,\n set: /** @this {Element} */ function(htmlString) {\n const isConnected = Utilities.isConnected(this);\n\n // NOTE: In IE11, when using the native `innerHTML` setter, all nodes\n // that were previously descendants of the context element have all of\n // their children removed as part of the set - the entire subtree is\n // 'disassembled'. This work around walks the subtree *before* using the\n // native setter.\n /** @type {!Array|undefined} */\n let removedElements = undefined;\n if (isConnected) {\n removedElements = [];\n Utilities.walkDeepDescendantElements(this, element => {\n if (element !== this) {\n removedElements.push(element);\n }\n });\n }\n\n baseDescriptor.set.call(this, htmlString);\n\n if (removedElements) {\n for (let i = 0; i < removedElements.length; i++) {\n const element = removedElements[i];\n if (element.__CE_state === CEState.custom) {\n internals.disconnectedCallback(element);\n }\n }\n }\n\n // Only create custom elements if this element's owner document is\n // associated with the registry.\n if (!this.ownerDocument.__CE_hasRegistry) {\n internals.patchTree(this);\n } else {\n internals.patchAndUpgradeTree(this);\n }\n return htmlString;\n },\n });\n }\n\n if (Native.Element_innerHTML && Native.Element_innerHTML.get) {\n patch_innerHTML(Element.prototype, Native.Element_innerHTML);\n } else if (Native.HTMLElement_innerHTML && Native.HTMLElement_innerHTML.get) {\n patch_innerHTML(HTMLElement.prototype, Native.HTMLElement_innerHTML);\n } else {\n\n /** @type {HTMLDivElement} */\n const rawDiv = Native.Document_createElement.call(document, 'div');\n\n internals.addPatch(function(element) {\n patch_innerHTML(element, {\n enumerable: true,\n configurable: true,\n // Implements getting `innerHTML` by performing an unpatched `cloneNode`\n // of the element and returning the resulting element's `innerHTML`.\n // TODO: Is this too expensive?\n get: /** @this {Element} */ function() {\n return Native.Node_cloneNode.call(this, true).innerHTML;\n },\n // Implements setting `innerHTML` by creating an unpatched element,\n // setting `innerHTML` of that element and replacing the target\n // element's children with those of the unpatched element.\n set: /** @this {Element} */ function(assignedValue) {\n // NOTE: re-route to `content` for `template` elements.\n // We need to do this because `template.appendChild` does not\n // route into `template.content`.\n /** @type {!Node} */\n const content = this.localName === 'template' ? (/** @type {!HTMLTemplateElement} */ (this)).content : this;\n rawDiv.innerHTML = assignedValue;\n\n while (content.childNodes.length > 0) {\n Native.Node_removeChild.call(content, content.childNodes[0]);\n }\n while (rawDiv.childNodes.length > 0) {\n Native.Node_appendChild.call(content, rawDiv.childNodes[0]);\n }\n },\n });\n });\n }\n\n\n Utilities.setPropertyUnchecked(Element.prototype, 'setAttribute',\n /**\n * @this {Element}\n * @param {string} name\n * @param {string} newValue\n */\n function(name, newValue) {\n // Fast path for non-custom elements.\n if (this.__CE_state !== CEState.custom) {\n return Native.Element_setAttribute.call(this, name, newValue);\n }\n\n const oldValue = Native.Element_getAttribute.call(this, name);\n Native.Element_setAttribute.call(this, name, newValue);\n newValue = Native.Element_getAttribute.call(this, name);\n internals.attributeChangedCallback(this, name, oldValue, newValue, null);\n });\n\n Utilities.setPropertyUnchecked(Element.prototype, 'setAttributeNS',\n /**\n * @this {Element}\n * @param {?string} namespace\n * @param {string} name\n * @param {string} newValue\n */\n function(namespace, name, newValue) {\n // Fast path for non-custom elements.\n if (this.__CE_state !== CEState.custom) {\n return Native.Element_setAttributeNS.call(this, namespace, name, newValue);\n }\n\n const oldValue = Native.Element_getAttributeNS.call(this, namespace, name);\n Native.Element_setAttributeNS.call(this, namespace, name, newValue);\n newValue = Native.Element_getAttributeNS.call(this, namespace, name);\n internals.attributeChangedCallback(this, name, oldValue, newValue, namespace);\n });\n\n Utilities.setPropertyUnchecked(Element.prototype, 'removeAttribute',\n /**\n * @this {Element}\n * @param {string} name\n */\n function(name) {\n // Fast path for non-custom elements.\n if (this.__CE_state !== CEState.custom) {\n return Native.Element_removeAttribute.call(this, name);\n }\n\n const oldValue = Native.Element_getAttribute.call(this, name);\n Native.Element_removeAttribute.call(this, name);\n if (oldValue !== null) {\n internals.attributeChangedCallback(this, name, oldValue, null, null);\n }\n });\n\n Utilities.setPropertyUnchecked(Element.prototype, 'removeAttributeNS',\n /**\n * @this {Element}\n * @param {?string} namespace\n * @param {string} name\n */\n function(namespace, name) {\n // Fast path for non-custom elements.\n if (this.__CE_state !== CEState.custom) {\n return Native.Element_removeAttributeNS.call(this, namespace, name);\n }\n\n const oldValue = Native.Element_getAttributeNS.call(this, namespace, name);\n Native.Element_removeAttributeNS.call(this, namespace, name);\n // In older browsers, `Element#getAttributeNS` may return the empty string\n // instead of null if the attribute does not exist. For details, see;\n // https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttributeNS#Notes\n const newValue = Native.Element_getAttributeNS.call(this, namespace, name);\n if (oldValue !== newValue) {\n internals.attributeChangedCallback(this, name, oldValue, newValue, namespace);\n }\n });\n\n\n function patch_insertAdjacentElement(destination, baseMethod) {\n Utilities.setPropertyUnchecked(destination, 'insertAdjacentElement',\n /**\n * @this {Element}\n * @param {string} where\n * @param {!Element} element\n * @return {?Element}\n */\n function(where, element) {\n const wasConnected = Utilities.isConnected(element);\n const insertedElement = /** @type {!Element} */\n (baseMethod.call(this, where, element));\n\n if (wasConnected) {\n internals.disconnectTree(element);\n }\n\n if (Utilities.isConnected(insertedElement)) {\n internals.connectTree(element);\n }\n return insertedElement;\n });\n }\n\n if (Native.HTMLElement_insertAdjacentElement) {\n patch_insertAdjacentElement(HTMLElement.prototype, Native.HTMLElement_insertAdjacentElement);\n } else if (Native.Element_insertAdjacentElement) {\n patch_insertAdjacentElement(Element.prototype, Native.Element_insertAdjacentElement);\n } else {\n console.warn('Custom Elements: `Element#insertAdjacentElement` was not patched.');\n }\n\n\n PatchParentNode(internals, Element.prototype, {\n prepend: Native.Element_prepend,\n append: Native.Element_append,\n });\n\n PatchChildNode(internals, Element.prototype, {\n before: Native.Element_before,\n after: Native.Element_after,\n replaceWith: Native.Element_replaceWith,\n remove: Native.Element_remove,\n });\n};\n"]} \ No newline at end of file +{"version":3,"sources":["src/AlreadyConstructedMarker.js","src/Environment.js","src/EnvironmentProxy.js","src/CustomElementInternals.js","src/Utilities.js","src/CustomElementState.js","src/DocumentConstructionObserver.js","src/Deferred.js","src/CustomElementRegistry.js","src/Patch/HTMLElement.js","src/custom-elements.js","src/Patch/Interface/ParentNode.js","src/Patch/Document.js","src/Patch/Node.js","src/Patch/Interface/ChildNode.js","src/Patch/Element.js"],"names":["$jscompDefaultExport","AlreadyConstructedMarker","getOwnPropertyDescriptors$$module$$src$Environment","getOwnPropertyDescriptors","target","clone","keys","Object","getOwnPropertyNames","i","length","key","getOwnPropertyDescriptor","Document","window","prototype","Element","HTMLElement","MutationObserver","Node","getter$$module$$src$EnvironmentProxy","descriptor","get","undefined","method$$module$$src$EnvironmentProxy","value","createElementMethod","method","createElement","createElementNSMethod","createElementNS","createTextNodeMethod","createTextNode","importNodeMethod","importNode","readyStateGetter","getter","readyState","attachShadowMethod","attachShadow","getAttributeMethod","getAttribute","getAttributeNSMethod","getAttributeNS","localNameGetter","localName","removeAttributeMethod","removeAttribute","removeAttributeNSMethod","removeAttributeNS","setAttributeMethod","setAttribute","setAttributeNSMethod","setAttributeNS","contentGetter","HTMLTemplateElement","content","constructor","observeMethod","observe","disconnectMethod","disconnect","addedNodesGetter","MutationRecord","addedNodes","addEventListenerMethod","addEventListener","addEventListener$$module$$src$EnvironmentProxy","node","callback","call","type","options","appendChildMethod","appendChild","childNodesGetter","childNodes","cloneNodeMethod","cloneNode","firstChildGetter","firstChild","insertBeforeMethod","insertBefore","isConnectedGetter","isConnected","nextSiblingGetter","nextSibling","nodeTypeGetter","nodeType","parentNodeGetter","parentNode","removeChildMethod","removeChild","replaceChildMethod","replaceChild","reservedTagList","Set","isValidCustomElementName$$module$$src$Utilities","isValidCustomElementName","reserved","has","validForm","test","isConnected$$module$$src$Utilities","nativeValue","current","__CE_isImportDocument","ShadowRoot","host","nextSiblingOrAncestorSibling$$module$$src$Utilities","nextSiblingOrAncestorSibling","root","start","walkDeepDescendantElements$$module$$src$Utilities","walkDeepDescendantElements","visitedImports","ELEMENT_NODE","element","name","import","add","child","shadowRoot","__CE_shadowRoot","setPropertyUnchecked$$module$$src$Utilities","setPropertyUnchecked","destination","CustomElementInternals","_localNameToDefinition","Map","_constructorToDefinition","_patches","_hasPatches","setDefinition","definition","set","addPatch","listener","push","patchTree","patch","__CE_patched","connectTree","elements","custom","__CE_state","connectedCallback","upgradeElement","disconnectTree","disconnectedCallback","patchAndUpgradeTree","gatherElements","__CE_hasRegistry","__CE_documentLoadHandled","delete","localNameToDefinition","constructionStack","result","Error","pop","e","failed","__CE_definition","attributeChangedCallback","observedAttributes","oldValue","newValue","namespace","indexOf","DocumentConstructionObserver","internals","doc","_internals","_document","_observer","_handleMutations","bind","childList","subtree","mutations","j","Deferred","_resolve","_value","_promise","Promise","resolve","CustomElementRegistry","_elementDefinitionIsRunning","_whenDefinedDeferred","_flushCallback","this._flushCallback","fn","_flushPending","_unflushedLocalNames","_documentConstructionObserver","document","define","Function","TypeError","SyntaxError","adoptedCallback","getCallback","callbackValue","_flush","shift","deferred","whenDefined","reject","prior","polyfillWrapFlushCallback","outer","inner","flush","$jscompDefaultExport$$module$$src$Patch$HTMLElement","setPrototypeOf","lastIndex","$jscompDefaultExport$$module$$src$Patch$Interface$ParentNode","builtIn","connectedBefore","nodes","filter","prepend","apply","append","$jscompDefaultExport$$module$$src$Patch$Document","deep","NS_HTML","$jscompDefaultExport$$module$$src$Patch$Node","patch_textContent","baseDescriptor","defineProperty","enumerable","configurable","assignedValue","TEXT_NODE","removedNodes","childNodesLength","Array","refNode","DocumentFragment","insertedNodes","slice","nativeResult","nodeWasConnected","ownerDocument","nodeToInsert","nodeToRemove","nodeToInsertWasConnected","thisIsConnected","textContent","parts","join","$jscompDefaultExport$$module$$src$Patch$Interface$ChildNode","before","after","replaceWith","remove","wasConnected","$jscompDefaultExport$$module$$src$Patch$Element","patch_innerHTML","htmlString","removedElements","patch_insertAdjacentElement","baseMethod","where","insertedElement","init","console","warn","innerHTML","rawDiv","priorCustomElements","customElements"],"mappings":"A;aASA,IAAAA,EAAe,IAFfC,QAAA,EAAA,E,CCPAC,QAASC,EAAyB,CAACC,CAAD,CAAS,CAIzC,IAHA,IAAMC,EAAQ,EAAd,CAEMC,EAAOC,MAAAC,oBAAA,CAA2BJ,CAA3B,CAFb,CAGSK,EAAI,CAAb,CAAgBA,CAAhB,CAAoBH,CAAAI,OAApB,CAAiCD,CAAA,EAAjC,CAAsC,CACpC,IAAME,EAAML,CAAA,CAAKG,CAAL,CACZJ,EAAA,CAAMM,CAAN,CAAA,CAAaJ,MAAAK,yBAAA,CAAgCR,CAAhC,CAAwCO,CAAxC,CAFuB,CAKtC,MAAON,EATkC,CAYpC,IAAMQ,EAAWV,CAAA,CAA0BW,MAAAD,SAAAE,UAA1B,CAAjB,CACMC,EAAUb,CAAA,CAA0BW,MAAAE,QAAAD,UAA1B,CADhB,CAEME,EAAcd,CAAA,CAA0BW,MAAAG,YAAAF,UAA1B,CAFpB,CAIMG,EAAmBf,CAAA,CAA0BW,MAAAI,iBAAAH,UAA1B,CAJzB,CAMMI,EAAOhB,CAAA,CAA0BW,MAAAK,KAAAJ,UAA1B,C,CChBLK,QAAA,EAAA,CAAAC,CAAA,CAAc,CAAA,MAAAA,EAAA,CAAaA,CAAAC,IAAb,CAA8B,QAAA,EAAMC,EAApC,CACdC,QAAA,EAAA,CAAAH,CAAA,CAAc,CAAA,MAAAA,EAAA,CAAaA,CAAAI,MAAb,CAAgC,QAAA,EAAMF,EAAtC;AAI7B,IAAMG,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M,MAAOA,EAAA,IAHb,CAGwD,CAEtD,IAAMtG,EAAY,IPrBL3C,CMKA/H,GCkBb,EEjBaA,GFkBb,EGpBaA,GHqBb,EKjBaA,GLkBb,EAGAoM,SAAA5C,iBAAA,CAA4B,CAAA,CAG5B,KAAMyH,eAAiB,IF5BVtF,CE4BU,CAA0BjB,CAA1B,CAEvBnK,OAAAgO,eAAA,CAAsBzN,MAAtB,CAA8B,gBAA9B,CAAgD,CAC9C2N,aAAc,CAAA,CADgC,CAE9CD,WAAY,CAAA,CAFkC,CAG9C/M,MAAOwP,cAHuC,CAAhD,CAfsD","file":"custom-elements.min.js","sourcesContent":["/**\n * This class exists only to work around Closure's lack of a way to describe\n * singletons. It represents the 'already constructed marker' used in custom\n * element construction stacks.\n *\n * https://html.spec.whatwg.org/#concept-already-constructed-marker\n */\nclass AlreadyConstructedMarker {}\n\nexport default new AlreadyConstructedMarker();\n","function getOwnPropertyDescriptors(target) {\n const clone = {};\n\n const keys = Object.getOwnPropertyNames(target);\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n clone[key] = Object.getOwnPropertyDescriptor(target, key);\n }\n\n return clone;\n}\n\nexport const Document = getOwnPropertyDescriptors(window.Document.prototype);\nexport const Element = getOwnPropertyDescriptors(window.Element.prototype);\nexport const HTMLElement = getOwnPropertyDescriptors(window.HTMLElement.prototype);\nexport const HTMLTemplateElement = getOwnPropertyDescriptors(window.HTMLElement.prototype);\nexport const MutationObserver = getOwnPropertyDescriptors(window.MutationObserver.prototype);\nexport const MutationRecord = getOwnPropertyDescriptors(window.MutationRecord.prototype);\nexport const Node = getOwnPropertyDescriptors(window.Node.prototype);\n","import * as Env from './Environment.js';\n\nconst getter = descriptor => descriptor ? descriptor.get : () => undefined;\nconst method = descriptor => descriptor ? descriptor.value : () => undefined;\n\n// Document\n\nconst createElementMethod = method(Env.Document.createElement);\nexport const createElement = (doc, localName) => createElementMethod.call(doc, localName);\n\nconst createElementNSMethod = method(Env.Document.createElementNS);\nexport const createElementNS = (doc, namespace, qualifiedName) => createElementNSMethod.call(doc, namespace, qualifiedName);\n\nconst createTextNodeMethod = method(Env.Document.createTextNode);\nexport const createTextNode = (doc, localName) => createTextNodeMethod.call(doc, localName);\n\nconst importNodeMethod = method(Env.Document.importNode);\nexport const importNode = (doc, node, deep) => importNodeMethod.call(doc, node, deep);\n\nconst readyStateGetter = getter(Env.Document.readyState);\nexport const readyState = doc => readyStateGetter.call(doc);\n\n// Element\n\nconst attachShadowMethod = method(Env.Element.attachShadow);\nexport const attachShadow = (node, options) => attachShadowMethod.call(node, options);\n\nconst getAttributeMethod = method(Env.Element.getAttribute);\nexport const getAttribute = (node, name) => getAttributeMethod.call(node, name);\n\nconst getAttributeNSMethod = method(Env.Element.getAttributeNS);\nexport const getAttributeNS = (node, ns, name) => getAttributeNSMethod.call(node, ns, name);\n\nconst localNameGetter = getter(Env.Element.localName);\nexport const localName = node => localNameGetter.call(node);\n\nconst removeAttributeMethod = method(Env.Element.removeAttribute);\nexport const removeAttribute = (node, name) => removeAttributeMethod.call(node, name);\n\nconst removeAttributeNSMethod = method(Env.Element.removeAttributeNS);\nexport const removeAttributeNS = (node, ns, name) => removeAttributeNSMethod.call(node, ns, name);\n\nconst setAttributeMethod = method(Env.Element.setAttribute);\nexport const setAttribute = (node, name, value) => setAttributeMethod.call(node, name, value);\n\nconst setAttributeNSMethod = method(Env.Element.setAttributeNS);\nexport const setAttributeNS = (node, ns, name, value) => setAttributeNSMethod.call(node, ns, name, value);\n\n// HTMLTemplateElement\n\nconst contentGetter = getter(Env.HTMLTemplateElement.content);\nexport const content = node => contentGetter.call(node);\n\n// MutationObserver\n\nexport const MutationObserver = method(Env.MutationObserver.constructor);\n\nconst observeMethod = method(Env.MutationObserver.observe);\nexport const observe = (mutationObserver, target, options) => observeMethod.call(mutationObserver, target, options);\n\nconst disconnectMethod = method(Env.MutationObserver.disconnect);\nexport const disconnect = mutationObserver => disconnectMethod.call(mutationObserver);\n\n// MutationRecord\n\nconst addedNodesGetter = getter(Env.MutationRecord.addedNodes);\nexport const addedNodes = node => addedNodesGetter.call(node);\n\n// Node\n\nconst addEventListenerMethod = method(Env.Node.addEventListener);\nexport const addEventListener = (node, type, callback, options) => addEventListenerMethod.call(node, type, callback, options);\n\nconst appendChildMethod = method(Env.Node.appendChild);\nexport const appendChild = (node, deep) => appendChildMethod.call(node, deep);\n\nconst childNodesGetter = getter(Env.Node.childNodes);\nexport const childNodes = node => childNodesGetter.call(node);\n\nconst cloneNodeMethod = method(Env.Node.cloneNode);\nexport const cloneNode = (node, deep) => cloneNodeMethod.call(node, deep);\n\nconst firstChildGetter = getter(Env.Node.firstChild);\nexport const firstChild = node => firstChildGetter.call(node);\n\nconst insertBeforeMethod = method(Env.Node.insertBefore);\nexport const insertBefore = (node, newChild, refChild) => insertBeforeMethod.call(node, newChild, refChild);\n\nconst isConnectedGetter = getter(Env.Node.isConnected);\nexport const isConnected = node => isConnectedGetter.call(node);\n\nconst nextSiblingGetter = getter(Env.Node.nextSibling);\nexport const nextSibling = node => nextSiblingGetter.call(node);\n\nconst nodeTypeGetter = getter(Env.Node.nodeType);\nexport const nodeType = node => nodeTypeGetter.call(node);\n\nconst parentNodeGetter = getter(Env.Node.parentNode);\nexport const parentNode = node => parentNodeGetter.call(node);\n\nconst removeChildMethod = method(Env.Node.removeChild);\nexport const removeChild = (node, deep) => removeChildMethod.call(node, deep);\n\nconst replaceChildMethod = method(Env.Node.replaceChild);\nexport const replaceChild = (node, newChild, oldChild) => replaceChildMethod.call(node, newChild, oldChild);\n","import * as EnvProxy from './EnvironmentProxy.js';\nimport * as Utilities from './Utilities.js';\nimport CEState from './CustomElementState.js';\n\nexport default class CustomElementInternals {\n constructor() {\n /** @type {!Map} */\n this._localNameToDefinition = new Map();\n\n /** @type {!Map} */\n this._constructorToDefinition = new Map();\n\n /** @type {!Array} */\n this._patches = [];\n\n /** @type {boolean} */\n this._hasPatches = false;\n }\n\n /**\n * @param {string} localName\n * @param {!CustomElementDefinition} definition\n */\n setDefinition(localName, definition) {\n this._localNameToDefinition.set(localName, definition);\n this._constructorToDefinition.set(definition.constructor, definition);\n }\n\n /**\n * @param {string} localName\n * @return {!CustomElementDefinition|undefined}\n */\n localNameToDefinition(localName) {\n return this._localNameToDefinition.get(localName);\n }\n\n /**\n * @param {!Function} constructor\n * @return {!CustomElementDefinition|undefined}\n */\n constructorToDefinition(constructor) {\n return this._constructorToDefinition.get(constructor);\n }\n\n /**\n * @param {!function(!Node)} listener\n */\n addPatch(listener) {\n this._hasPatches = true;\n this._patches.push(listener);\n }\n\n /**\n * @param {!Node} node\n */\n patchTree(node) {\n if (!this._hasPatches) return;\n\n Utilities.walkDeepDescendantElements(node, element => this.patch(element));\n }\n\n /**\n * @param {!Node} node\n */\n patch(node) {\n if (!this._hasPatches) return;\n\n if (node.__CE_patched) return;\n node.__CE_patched = true;\n\n for (let i = 0; i < this._patches.length; i++) {\n this._patches[i](node);\n }\n }\n\n /**\n * @param {!Node} root\n */\n connectTree(root) {\n const elements = [];\n\n Utilities.walkDeepDescendantElements(root, element => elements.push(element));\n\n for (let i = 0; i < elements.length; i++) {\n const element = elements[i];\n if (element.__CE_state === CEState.custom) {\n this.connectedCallback(element);\n } else {\n this.upgradeElement(element);\n }\n }\n }\n\n /**\n * @param {!Node} root\n */\n disconnectTree(root) {\n const elements = [];\n\n Utilities.walkDeepDescendantElements(root, element => elements.push(element));\n\n for (let i = 0; i < elements.length; i++) {\n const element = elements[i];\n if (element.__CE_state === CEState.custom) {\n this.disconnectedCallback(element);\n }\n }\n }\n\n /**\n * Upgrades all uncustomized custom elements at and below a root node for\n * which there is a definition. When custom element reaction callbacks are\n * assumed to be called synchronously (which, by the current DOM / HTML spec\n * definitions, they are *not*), callbacks for both elements customized\n * synchronously by the parser and elements being upgraded occur in the same\n * relative order.\n *\n * NOTE: This function, when used to simulate the construction of a tree that\n * is already created but not customized (i.e. by the parser), does *not*\n * prevent the element from reading the 'final' (true) state of the tree. For\n * example, the element, during truly synchronous parsing / construction would\n * see that it contains no children as they have not yet been inserted.\n * However, this function does not modify the tree, the element will\n * (incorrectly) have children. Additionally, self-modification restrictions\n * for custom element constructors imposed by the DOM spec are *not* enforced.\n *\n *\n * The following nested list shows the steps extending down from the HTML\n * spec's parsing section that cause elements to be synchronously created and\n * upgraded:\n *\n * The \"in body\" insertion mode:\n * https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody\n * - Switch on token:\n * .. other cases ..\n * -> Any other start tag\n * - [Insert an HTML element](below) for the token.\n *\n * Insert an HTML element:\n * https://html.spec.whatwg.org/multipage/syntax.html#insert-an-html-element\n * - Insert a foreign element for the token in the HTML namespace:\n * https://html.spec.whatwg.org/multipage/syntax.html#insert-a-foreign-element\n * - Create an element for a token:\n * https://html.spec.whatwg.org/multipage/syntax.html#create-an-element-for-the-token\n * - Will execute script flag is true?\n * - (Element queue pushed to the custom element reactions stack.)\n * - Create an element:\n * https://dom.spec.whatwg.org/#concept-create-element\n * - Sync CE flag is true?\n * - Constructor called.\n * - Self-modification restrictions enforced.\n * - Sync CE flag is false?\n * - (Upgrade reaction enqueued.)\n * - Attributes appended to element.\n * (`attributeChangedCallback` reactions enqueued.)\n * - Will execute script flag is true?\n * - (Element queue popped from the custom element reactions stack.\n * Reactions in the popped stack are invoked.)\n * - (Element queue pushed to the custom element reactions stack.)\n * - Insert the element:\n * https://dom.spec.whatwg.org/#concept-node-insert\n * - Shadow-including descendants are connected. During parsing\n * construction, there are no shadow-*excluding* descendants.\n * However, the constructor may have validly attached a shadow\n * tree to itself and added descendants to that shadow tree.\n * (`connectedCallback` reactions enqueued.)\n * - (Element queue popped from the custom element reactions stack.\n * Reactions in the popped stack are invoked.)\n *\n * @param {!Node} root\n * @param {!Set=} visitedImports\n */\n patchAndUpgradeTree(root, visitedImports = new Set()) {\n const elements = [];\n\n const gatherElements = element => {\n if (EnvProxy.localName(element) === 'link' && EnvProxy.getAttribute(element, 'rel') === 'import') {\n // The HTML Imports polyfill sets a descendant element of the link to\n // the `import` property, specifically this is *not* a Document.\n const importNode = /** @type {?Node} */ (element.import);\n\n if (importNode instanceof Node && importNode.readyState === 'complete') {\n importNode.__CE_isImportDocument = true;\n\n // Connected links are associated with the registry.\n importNode.__CE_hasRegistry = true;\n } else {\n // If this link's import root is not available, its contents can't be\n // walked. Wait for 'load' and walk it when it's ready.\n EnvProxy.addEventListener(element, 'load', () => {\n const importNode = /** @type {!Node} */ (element.import);\n\n if (importNode.__CE_documentLoadHandled) return;\n importNode.__CE_documentLoadHandled = true;\n\n importNode.__CE_isImportDocument = true;\n\n // Connected links are associated with the registry.\n importNode.__CE_hasRegistry = true;\n\n // Clone the `visitedImports` set that was populated sync during\n // the `patchAndUpgradeTree` call that caused this 'load' handler to\n // be added. Then, remove *this* link's import node so that we can\n // walk that import again, even if it was partially walked later\n // during the same `patchAndUpgradeTree` call.\n const clonedVisitedImports = new Set(visitedImports);\n visitedImports.delete(importNode);\n\n this.patchAndUpgradeTree(importNode, visitedImports);\n });\n }\n } else {\n elements.push(element);\n }\n };\n\n // `walkDeepDescendantElements` populates (and internally checks against)\n // `visitedImports` when traversing a loaded import.\n Utilities.walkDeepDescendantElements(root, gatherElements, visitedImports);\n\n if (this._hasPatches) {\n for (let i = 0; i < elements.length; i++) {\n this.patch(elements[i]);\n }\n }\n\n for (let i = 0; i < elements.length; i++) {\n this.upgradeElement(elements[i]);\n }\n }\n\n /**\n * @param {!Element} element\n */\n upgradeElement(element) {\n const currentState = element.__CE_state;\n if (currentState !== undefined) return;\n\n const definition = this.localNameToDefinition(element.localName);\n if (!definition) return;\n\n definition.constructionStack.push(element);\n\n const constructor = definition.constructor;\n try {\n try {\n let result = new (constructor)();\n if (result !== element) {\n throw new Error('The custom element constructor did not produce the element being upgraded.');\n }\n } finally {\n definition.constructionStack.pop();\n }\n } catch (e) {\n element.__CE_state = CEState.failed;\n throw e;\n }\n\n element.__CE_state = CEState.custom;\n element.__CE_definition = definition;\n\n if (definition.attributeChangedCallback) {\n const observedAttributes = definition.observedAttributes;\n for (let i = 0; i < observedAttributes.length; i++) {\n const name = observedAttributes[i];\n const value = EnvProxy.getAttribute(element, name);\n if (value !== null) {\n this.attributeChangedCallback(element, name, null, value, null);\n }\n }\n }\n\n if (Utilities.isConnected(element)) {\n this.connectedCallback(element);\n }\n }\n\n /**\n * @param {!Element} element\n */\n connectedCallback(element) {\n const definition = element.__CE_definition;\n if (definition.connectedCallback) {\n definition.connectedCallback.call(element);\n }\n }\n\n /**\n * @param {!Element} element\n */\n disconnectedCallback(element) {\n const definition = element.__CE_definition;\n if (definition.disconnectedCallback) {\n definition.disconnectedCallback.call(element);\n }\n }\n\n /**\n * @param {!Element} element\n * @param {string} name\n * @param {?string} oldValue\n * @param {?string} newValue\n * @param {?string} namespace\n */\n attributeChangedCallback(element, name, oldValue, newValue, namespace) {\n const definition = element.__CE_definition;\n if (\n definition.attributeChangedCallback &&\n definition.observedAttributes.indexOf(name) > -1\n ) {\n definition.attributeChangedCallback.call(element, name, oldValue, newValue, namespace);\n }\n }\n}\n","import * as EnvProxy from './EnvironmentProxy.js';\n\nconst reservedTagList = new Set([\n 'annotation-xml',\n 'color-profile',\n 'font-face',\n 'font-face-src',\n 'font-face-uri',\n 'font-face-format',\n 'font-face-name',\n 'missing-glyph',\n]);\n\n/**\n * @param {string} localName\n * @returns {boolean}\n */\nexport function isValidCustomElementName(localName) {\n const reserved = reservedTagList.has(localName);\n const validForm = /^[a-z][.0-9_a-z]*-[\\-.0-9_a-z]*$/.test(localName);\n return !reserved && validForm;\n}\n\n/**\n * @private\n * @param {!Node} node\n * @return {boolean}\n */\nexport function isConnected(node) {\n // Use `Node#isConnected`, if defined.\n const nativeValue = EnvProxy.isConnected(node);\n if (nativeValue !== undefined) {\n return nativeValue;\n }\n\n /** @type {?Node|undefined} */\n let current = node;\n while (current && !(current.__CE_isImportDocument || current instanceof Document)) {\n current = EnvProxy.parentNode(current) || (window.ShadowRoot && current instanceof ShadowRoot ? current.host : undefined);\n }\n return !!(current && (current.__CE_isImportDocument || current instanceof Document));\n}\n\n/**\n * @param {!Node} root\n * @param {!Node} start\n * @return {?Node}\n */\nfunction nextSiblingOrAncestorSibling(root, start) {\n let node = start;\n while (node && node !== root && !EnvProxy.nextSibling(node)) {\n node = EnvProxy.parentNode(node);\n }\n return (!node || node === root) ? null : EnvProxy.nextSibling(node);\n}\n\n/**\n * @param {!Node} root\n * @param {!Node} start\n * @return {?Node}\n */\nfunction nextNode(root, start) {\n return EnvProxy.firstChild(start) || nextSiblingOrAncestorSibling(root, start);\n}\n\n/**\n * @param {!Node} root\n * @param {!function(!Element)} callback\n * @param {!Set=} visitedImports\n */\nexport function walkDeepDescendantElements(root, callback, visitedImports = new Set()) {\n let node = root;\n while (node) {\n if (EnvProxy.nodeType(node) === Node.ELEMENT_NODE) {\n const element = /** @type {!Element} */(node);\n\n callback(element);\n\n const localName = EnvProxy.localName(element);\n if (localName === 'link' && EnvProxy.getAttribute(element, 'rel') === 'import') {\n // If this import (polyfilled or not) has it's root node available,\n // walk it.\n const importNode = /** @type {!Node} */ (element.import);\n if (importNode instanceof Node && !visitedImports.has(importNode)) {\n // Prevent multiple walks of the same import root.\n visitedImports.add(importNode);\n\n for (let child = EnvProxy.firstChild(importNode); child; child = EnvProxy.nextSibling(child)) {\n walkDeepDescendantElements(child, callback, visitedImports);\n }\n }\n\n // Ignore descendants of import links to prevent attempting to walk the\n // elements created by the HTML Imports polyfill that we just walked\n // above.\n node = nextSiblingOrAncestorSibling(root, element);\n continue;\n } else if (localName === 'template') {\n // Ignore descendants of templates. There shouldn't be any descendants\n // because they will be moved into `.content` during construction in\n // browsers that support template but, in case they exist and are still\n // waiting to be moved by a polyfill, they will be ignored.\n node = nextSiblingOrAncestorSibling(root, element);\n continue;\n }\n\n // Walk shadow roots.\n const shadowRoot = element.__CE_shadowRoot;\n if (shadowRoot) {\n for (let child = EnvProxy.firstChild(shadowRoot); child; child = EnvProxy.nextSibling(child)) {\n walkDeepDescendantElements(child, callback, visitedImports);\n }\n }\n }\n\n node = nextNode(root, node);\n }\n}\n\n/**\n * Used to suppress Closure's \"Modifying the prototype is only allowed if the\n * constructor is in the same scope\" warning without using\n * `@suppress {newCheckTypes, duplicate}` because `newCheckTypes` is too broad.\n *\n * @param {!Object} destination\n * @param {string} name\n * @param {*} value\n */\nexport function setPropertyUnchecked(destination, name, value) {\n destination[name] = value;\n}\n","/**\n * @enum {number}\n */\nconst CustomElementState = {\n custom: 1,\n failed: 2,\n};\n\nexport default CustomElementState;\n","import * as EnvProxy from './EnvironmentProxy.js';\nimport CustomElementInternals from './CustomElementInternals.js';\n\nexport default class DocumentConstructionObserver {\n constructor(internals, doc) {\n /**\n * @type {!CustomElementInternals}\n */\n this._internals = internals;\n\n /**\n * @type {!Document}\n */\n this._document = doc;\n\n /**\n * @type {MutationObserver|undefined}\n */\n this._observer = undefined;\n\n\n // Simulate tree construction for all currently accessible nodes in the\n // document.\n this._internals.patchAndUpgradeTree(this._document);\n\n if (EnvProxy.readyState(this._document) === 'loading') {\n this._observer = new EnvProxy.MutationObserver(this._handleMutations.bind(this));\n\n // Nodes created by the parser are given to the observer *before* the next\n // task runs. Inline scripts are run in a new task. This means that the\n // observer will be able to handle the newly parsed nodes before the inline\n // script is run.\n EnvProxy.observe(this._observer, this._document, {\n childList: true,\n subtree: true,\n });\n }\n }\n\n disconnect() {\n if (this._observer) {\n EnvProxy.disconnect(this._observer);\n }\n }\n\n /**\n * @param {!Array} mutations\n */\n _handleMutations(mutations) {\n // Once the document's `readyState` is 'interactive' or 'complete', all new\n // nodes created within that document will be the result of script and\n // should be handled by patching.\n const readyState = EnvProxy.readyState(this._document);\n if (readyState === 'interactive' || readyState === 'complete') {\n this.disconnect();\n }\n\n for (let i = 0; i < mutations.length; i++) {\n const addedNodes = EnvProxy.addedNodes(mutations[i]);\n for (let j = 0; j < addedNodes.length; j++) {\n const node = addedNodes[j];\n this._internals.patchAndUpgradeTree(node);\n }\n }\n }\n}\n","/**\n * @template T\n */\nexport default class Deferred {\n constructor() {\n /**\n * @private\n * @type {T|undefined}\n */\n this._value = undefined;\n\n /**\n * @private\n * @type {Function|undefined}\n */\n this._resolve = undefined;\n\n /**\n * @private\n * @type {!Promise}\n */\n this._promise = new Promise(resolve => {\n this._resolve = resolve;\n\n if (this._value) {\n resolve(this._value);\n }\n });\n }\n\n /**\n * @param {T} value\n */\n resolve(value) {\n if (this._value) {\n throw new Error('Already resolved.');\n }\n\n this._value = value;\n\n if (this._resolve) {\n this._resolve(value);\n }\n }\n\n /**\n * @return {!Promise}\n */\n toPromise() {\n return this._promise;\n }\n}\n","import CustomElementInternals from './CustomElementInternals.js';\nimport DocumentConstructionObserver from './DocumentConstructionObserver.js';\nimport Deferred from './Deferred.js';\nimport * as Utilities from './Utilities.js';\n\n/**\n * @unrestricted\n */\nexport default class CustomElementRegistry {\n\n /**\n * @param {!CustomElementInternals} internals\n */\n constructor(internals) {\n /**\n * @private\n * @type {boolean}\n */\n this._elementDefinitionIsRunning = false;\n\n /**\n * @private\n * @type {!CustomElementInternals}\n */\n this._internals = internals;\n\n /**\n * @private\n * @type {!Map>}\n */\n this._whenDefinedDeferred = new Map();\n\n /**\n * The default flush callback triggers the document walk synchronously.\n * @private\n * @type {!Function}\n */\n this._flushCallback = fn => fn();\n\n /**\n * @private\n * @type {boolean}\n */\n this._flushPending = false;\n\n /**\n * @private\n * @type {!Array}\n */\n this._unflushedLocalNames = [];\n\n /**\n * @private\n * @type {!DocumentConstructionObserver}\n */\n this._documentConstructionObserver = new DocumentConstructionObserver(internals, document);\n }\n\n /**\n * @param {string} localName\n * @param {!Function} constructor\n */\n define(localName, constructor) {\n if (!(constructor instanceof Function)) {\n throw new TypeError('Custom element constructors must be functions.');\n }\n\n if (!Utilities.isValidCustomElementName(localName)) {\n throw new SyntaxError(`The element name '${localName}' is not valid.`);\n }\n\n if (this._internals.localNameToDefinition(localName)) {\n throw new Error(`A custom element with name '${localName}' has already been defined.`);\n }\n\n if (this._elementDefinitionIsRunning) {\n throw new Error('A custom element is already being defined.');\n }\n this._elementDefinitionIsRunning = true;\n\n let connectedCallback;\n let disconnectedCallback;\n let adoptedCallback;\n let attributeChangedCallback;\n let observedAttributes;\n try {\n /** @type {!Object} */\n const prototype = constructor.prototype;\n if (!(prototype instanceof Object)) {\n throw new TypeError('The custom element constructor\\'s prototype is not an object.');\n }\n\n function getCallback(name) {\n const callbackValue = prototype[name];\n if (callbackValue !== undefined && !(callbackValue instanceof Function)) {\n throw new Error(`The '${name}' callback must be a function.`);\n }\n return callbackValue;\n }\n\n connectedCallback = getCallback('connectedCallback');\n disconnectedCallback = getCallback('disconnectedCallback');\n adoptedCallback = getCallback('adoptedCallback');\n attributeChangedCallback = getCallback('attributeChangedCallback');\n observedAttributes = constructor['observedAttributes'] || [];\n } catch (e) {\n return;\n } finally {\n this._elementDefinitionIsRunning = false;\n }\n\n const definition = {\n localName,\n constructor,\n connectedCallback,\n disconnectedCallback,\n adoptedCallback,\n attributeChangedCallback,\n observedAttributes,\n constructionStack: [],\n };\n\n this._internals.setDefinition(localName, definition);\n\n this._unflushedLocalNames.push(localName);\n\n // If we've already called the flush callback and it hasn't called back yet,\n // don't call it again.\n if (!this._flushPending) {\n this._flushPending = true;\n this._flushCallback(() => this._flush());\n }\n }\n\n _flush() {\n // If no new definitions were defined, don't attempt to flush. This could\n // happen if a flush callback keeps the function it is given and calls it\n // multiple times.\n if (this._flushPending === false) return;\n\n this._flushPending = false;\n this._internals.patchAndUpgradeTree(document);\n\n while (this._unflushedLocalNames.length > 0) {\n const localName = this._unflushedLocalNames.shift();\n const deferred = this._whenDefinedDeferred.get(localName);\n if (deferred) {\n deferred.resolve(undefined);\n }\n }\n }\n\n /**\n * @param {string} localName\n * @return {Function|undefined}\n */\n get(localName) {\n const definition = this._internals.localNameToDefinition(localName);\n if (definition) {\n return definition.constructor;\n }\n\n return undefined;\n }\n\n /**\n * @param {string} localName\n * @return {!Promise}\n */\n whenDefined(localName) {\n if (!Utilities.isValidCustomElementName(localName)) {\n return Promise.reject(new SyntaxError(`'${localName}' is not a valid custom element name.`));\n }\n\n const prior = this._whenDefinedDeferred.get(localName);\n if (prior) {\n return prior.toPromise();\n }\n\n const deferred = new Deferred();\n this._whenDefinedDeferred.set(localName, deferred);\n\n const definition = this._internals.localNameToDefinition(localName);\n // Resolve immediately only if the given local name has a definition *and*\n // the full document walk to upgrade elements with that local name has\n // already happened.\n if (definition && this._unflushedLocalNames.indexOf(localName) === -1) {\n deferred.resolve(undefined);\n }\n\n return deferred.toPromise();\n }\n\n polyfillWrapFlushCallback(outer) {\n this._documentConstructionObserver.disconnect();\n const inner = this._flushCallback;\n this._flushCallback = flush => outer(() => inner(flush));\n }\n}\n\n// Closure compiler exports.\nwindow['CustomElementRegistry'] = CustomElementRegistry;\nCustomElementRegistry.prototype['define'] = CustomElementRegistry.prototype.define;\nCustomElementRegistry.prototype['get'] = CustomElementRegistry.prototype.get;\nCustomElementRegistry.prototype['whenDefined'] = CustomElementRegistry.prototype.whenDefined;\nCustomElementRegistry.prototype['polyfillWrapFlushCallback'] = CustomElementRegistry.prototype.polyfillWrapFlushCallback;\n","import * as Env from '../Environment.js';\nimport * as EnvProxy from '../EnvironmentProxy.js';\nimport CustomElementInternals from '../CustomElementInternals.js';\nimport CEState from '../CustomElementState.js';\nimport AlreadyConstructedMarker from '../AlreadyConstructedMarker.js';\n\n/**\n * @param {!CustomElementInternals} internals\n */\nexport default function(internals) {\n window['HTMLElement'] = (function() {\n /**\n * @type {function(new: HTMLElement): !HTMLElement}\n */\n function HTMLElement() {\n // This should really be `new.target` but `new.target` can't be emulated\n // in ES5. Assuming the user keeps the default value of the constructor's\n // prototype's `constructor` property, this is equivalent.\n /** @type {!Function} */\n const constructor = this.constructor;\n\n const definition = internals.constructorToDefinition(constructor);\n if (!definition) {\n throw new Error('The custom element being constructed was not registered with `customElements`.');\n }\n\n const constructionStack = definition.constructionStack;\n\n if (constructionStack.length === 0) {\n const element = EnvProxy.createElement(document, definition.localName);\n Object.setPrototypeOf(element, constructor.prototype);\n element.__CE_state = CEState.custom;\n element.__CE_definition = definition;\n internals.patch(element);\n return element;\n }\n\n const lastIndex = constructionStack.length - 1;\n const element = constructionStack[lastIndex];\n if (element === AlreadyConstructedMarker) {\n throw new Error('The HTMLElement constructor was either called reentrantly for this constructor or called multiple times.');\n }\n constructionStack[lastIndex] = AlreadyConstructedMarker;\n\n Object.setPrototypeOf(element, constructor.prototype);\n internals.patch(/** @type {!HTMLElement} */ (element));\n\n return element;\n }\n\n HTMLElement.prototype = Env.HTMLElement.constructor.value.prototype;\n\n return HTMLElement;\n })();\n};\n","/**\n * @license\n * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n */\n\nimport CustomElementInternals from './CustomElementInternals.js';\nimport CustomElementRegistry from './CustomElementRegistry.js';\n\nimport PatchHTMLElement from './Patch/HTMLElement.js';\nimport PatchDocument from './Patch/Document.js';\nimport PatchNode from './Patch/Node.js';\nimport PatchElement from './Patch/Element.js';\n\nconst priorCustomElements = window['customElements'];\n\nif (!priorCustomElements ||\n priorCustomElements['forcePolyfill'] ||\n (typeof priorCustomElements['define'] != 'function') ||\n (typeof priorCustomElements['get'] != 'function')) {\n /** @type {!CustomElementInternals} */\n const internals = new CustomElementInternals();\n\n PatchHTMLElement(internals);\n PatchDocument(internals);\n PatchNode(internals);\n PatchElement(internals);\n\n // The main document is always associated with the registry.\n document.__CE_hasRegistry = true;\n\n /** @type {!CustomElementRegistry} */\n const customElements = new CustomElementRegistry(internals);\n\n Object.defineProperty(window, 'customElements', {\n configurable: true,\n enumerable: true,\n value: customElements,\n });\n}\n","import CustomElementInternals from '../../CustomElementInternals.js';\nimport * as Utilities from '../../Utilities.js';\n\n/**\n * @typedef {{\n * prepend: !function(...(!Node|string)),\n * append: !function(...(!Node|string)),\n * }}\n */\nlet ParentNodeNativeMethods;\n\n/**\n * @param {!CustomElementInternals} internals\n * @param {!Object} destination\n * @param {!ParentNodeNativeMethods} builtIn\n */\nexport default function(internals, destination, builtIn) {\n /**\n * @param {...(!Node|string)} nodes\n */\n destination['prepend'] = function(...nodes) {\n // TODO: Fix this for when one of `nodes` is a DocumentFragment!\n const connectedBefore = /** @type {!Array} */ (nodes.filter(node => {\n // DocumentFragments are not connected and will not be added to the list.\n return node instanceof Node && Utilities.isConnected(node);\n }));\n\n builtIn.prepend.apply(this, nodes);\n\n for (let i = 0; i < connectedBefore.length; i++) {\n internals.disconnectTree(connectedBefore[i]);\n }\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node instanceof Element) {\n internals.connectTree(node);\n }\n }\n }\n };\n\n /**\n * @param {...(!Node|string)} nodes\n */\n destination['append'] = function(...nodes) {\n // TODO: Fix this for when one of `nodes` is a DocumentFragment!\n const connectedBefore = /** @type {!Array} */ (nodes.filter(node => {\n // DocumentFragments are not connected and will not be added to the list.\n return node instanceof Node && Utilities.isConnected(node);\n }));\n\n builtIn.append.apply(this, nodes);\n\n for (let i = 0; i < connectedBefore.length; i++) {\n internals.disconnectTree(connectedBefore[i]);\n }\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node instanceof Element) {\n internals.connectTree(node);\n }\n }\n }\n };\n};\n","import * as Env from '../Environment.js';\nimport * as EnvProxy from '../EnvironmentProxy.js';\nimport CustomElementInternals from '../CustomElementInternals.js';\nimport * as Utilities from '../Utilities.js';\n\nimport PatchParentNode from './Interface/ParentNode.js';\n\n/**\n * @param {!CustomElementInternals} internals\n */\nexport default function(internals) {\n Utilities.setPropertyUnchecked(Document.prototype, 'createElement',\n /**\n * @this {Document}\n * @param {string} localName\n * @return {!Element}\n */\n function(localName) {\n // Only create custom elements if this document is associated with the registry.\n if (this.__CE_hasRegistry) {\n const definition = internals.localNameToDefinition(localName);\n if (definition) {\n return new (definition.constructor)();\n }\n }\n\n const result = /** @type {!Element} */\n (EnvProxy.createElement(this, localName));\n internals.patch(result);\n return result;\n });\n\n Utilities.setPropertyUnchecked(Document.prototype, 'importNode',\n /**\n * @this {Document}\n * @param {!Node} node\n * @param {boolean=} deep\n * @return {!Node}\n */\n function(node, deep) {\n const clone = EnvProxy.importNode(this, node, deep);\n // Only create custom elements if this document is associated with the registry.\n if (!this.__CE_hasRegistry) {\n internals.patchTree(clone);\n } else {\n internals.patchAndUpgradeTree(clone);\n }\n return clone;\n });\n\n const NS_HTML = \"http://www.w3.org/1999/xhtml\";\n\n Utilities.setPropertyUnchecked(Document.prototype, 'createElementNS',\n /**\n * @this {Document}\n * @param {?string} namespace\n * @param {string} localName\n * @return {!Element}\n */\n function(namespace, localName) {\n // Only create custom elements if this document is associated with the registry.\n if (this.__CE_hasRegistry && (namespace === null || namespace === NS_HTML)) {\n const definition = internals.localNameToDefinition(localName);\n if (definition) {\n return new (definition.constructor)();\n }\n }\n\n const result = /** @type {!Element} */\n (EnvProxy.createElementNS(this, namespace, localName));\n internals.patch(result);\n return result;\n });\n\n PatchParentNode(internals, Document.prototype, {\n prepend: (Env.Document.prepend || {}).value,\n append: (Env.Document.append || {}).value,\n });\n};\n","import * as Env from '../Environment.js';\nimport * as EnvProxy from '../EnvironmentProxy.js';\nimport CustomElementInternals from '../CustomElementInternals.js';\nimport * as Utilities from '../Utilities.js';\n\n/**\n * @param {!CustomElementInternals} internals\n */\nexport default function(internals) {\n // `Node#nodeValue` is implemented on `Attr`.\n // `Node#textContent` is implemented on `Attr`, `Element`.\n\n Utilities.setPropertyUnchecked(Node.prototype, 'insertBefore',\n /**\n * @this {Node}\n * @param {!Node} node\n * @param {?Node} refNode\n * @return {!Node}\n */\n function(node, refNode) {\n if (node instanceof DocumentFragment) {\n const insertedNodes = Array.prototype.slice.apply(EnvProxy.childNodes(node));\n const nativeResult = EnvProxy.insertBefore(this, node, refNode);\n\n // DocumentFragments can't be connected, so `disconnectTree` will never\n // need to be called on a DocumentFragment's children after inserting it.\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < insertedNodes.length; i++) {\n internals.connectTree(insertedNodes[i]);\n }\n }\n\n return nativeResult;\n }\n\n const nodeWasConnected = Utilities.isConnected(node);\n const nativeResult = EnvProxy.insertBefore(this, node, refNode);\n\n if (nodeWasConnected) {\n internals.disconnectTree(node);\n }\n\n if (Utilities.isConnected(this)) {\n internals.connectTree(node);\n }\n\n return nativeResult;\n });\n\n Utilities.setPropertyUnchecked(Node.prototype, 'appendChild',\n /**\n * @this {Node}\n * @param {!Node} node\n * @return {!Node}\n */\n function(node) {\n if (node instanceof DocumentFragment) {\n const insertedNodes = Array.prototype.slice.apply(EnvProxy.childNodes(node));\n const nativeResult = EnvProxy.appendChild(this, node);\n\n // DocumentFragments can't be connected, so `disconnectTree` will never\n // need to be called on a DocumentFragment's children after inserting it.\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < insertedNodes.length; i++) {\n internals.connectTree(insertedNodes[i]);\n }\n }\n\n return nativeResult;\n }\n\n const nodeWasConnected = Utilities.isConnected(node);\n const nativeResult = EnvProxy.appendChild(this, node);\n\n if (nodeWasConnected) {\n internals.disconnectTree(node);\n }\n\n if (Utilities.isConnected(this)) {\n internals.connectTree(node);\n }\n\n return nativeResult;\n });\n\n Utilities.setPropertyUnchecked(Node.prototype, 'cloneNode',\n /**\n * @this {Node}\n * @param {boolean=} deep\n * @return {!Node}\n */\n function(deep) {\n const clone = EnvProxy.cloneNode(this, deep);\n // Only create custom elements if this element's owner document is\n // associated with the registry.\n if (!this.ownerDocument.__CE_hasRegistry) {\n internals.patchTree(clone);\n } else {\n internals.patchAndUpgradeTree(clone);\n }\n return clone;\n });\n\n Utilities.setPropertyUnchecked(Node.prototype, 'removeChild',\n /**\n * @this {Node}\n * @param {!Node} node\n * @return {!Node}\n */\n function(node) {\n const nodeWasConnected = Utilities.isConnected(node);\n const nativeResult = EnvProxy.removeChild(this, node);\n\n if (nodeWasConnected) {\n internals.disconnectTree(node);\n }\n\n return nativeResult;\n });\n\n Utilities.setPropertyUnchecked(Node.prototype, 'replaceChild',\n /**\n * @this {Node}\n * @param {!Node} nodeToInsert\n * @param {!Node} nodeToRemove\n * @return {!Node}\n */\n function(nodeToInsert, nodeToRemove) {\n if (nodeToInsert instanceof DocumentFragment) {\n const insertedNodes = Array.prototype.slice.apply(EnvProxy.childNodes(nodeToInsert));\n const nativeResult = EnvProxy.replaceChild(this, nodeToInsert, nodeToRemove);\n\n // DocumentFragments can't be connected, so `disconnectTree` will never\n // need to be called on a DocumentFragment's children after inserting it.\n\n if (Utilities.isConnected(this)) {\n internals.disconnectTree(nodeToRemove);\n for (let i = 0; i < insertedNodes.length; i++) {\n internals.connectTree(insertedNodes[i]);\n }\n }\n\n return nativeResult;\n }\n\n const nodeToInsertWasConnected = Utilities.isConnected(nodeToInsert);\n const nativeResult = EnvProxy.replaceChild(this, nodeToInsert, nodeToRemove);\n const thisIsConnected = Utilities.isConnected(this);\n\n if (thisIsConnected) {\n internals.disconnectTree(nodeToRemove);\n }\n\n if (nodeToInsertWasConnected) {\n internals.disconnectTree(nodeToInsert);\n }\n\n if (thisIsConnected) {\n internals.connectTree(nodeToInsert);\n }\n\n return nativeResult;\n });\n\n\n function patch_textContent(destination, baseDescriptor) {\n Object.defineProperty(destination, 'textContent', {\n enumerable: baseDescriptor.enumerable,\n configurable: true,\n get: baseDescriptor.get,\n set: /** @this {Node} */ function(assignedValue) {\n // If this is a text node then there are no nodes to disconnect.\n if (this.nodeType === Node.TEXT_NODE) {\n baseDescriptor.set.call(this, assignedValue);\n return;\n }\n\n let removedNodes = undefined;\n // Checking for `firstChild` is faster than reading `childNodes.length`\n // to compare with 0.\n if (EnvProxy.firstChild(this)) {\n // Using `childNodes` is faster than `children`, even though we only\n // care about elements.\n const childNodes = EnvProxy.childNodes(this);\n const childNodesLength = childNodes.length;\n if (childNodesLength > 0 && Utilities.isConnected(this)) {\n // Copying an array by iterating is faster than using slice.\n removedNodes = new Array(childNodesLength);\n for (let i = 0; i < childNodesLength; i++) {\n removedNodes[i] = childNodes[i];\n }\n }\n }\n\n baseDescriptor.set.call(this, assignedValue);\n\n if (removedNodes) {\n for (let i = 0; i < removedNodes.length; i++) {\n internals.disconnectTree(removedNodes[i]);\n }\n }\n },\n });\n }\n\n if (Env.Node.textContent && Env.Node.textContent.get) {\n patch_textContent(Node.prototype, Env.Node.textContent);\n } else {\n internals.addPatch(function(element) {\n patch_textContent(element, {\n enumerable: true,\n configurable: true,\n // NOTE: This implementation of the `textContent` getter assumes that\n // text nodes' `textContent` getter will not be patched.\n get: /** @this {Node} */ function() {\n /** @type {!Array} */\n const parts = [];\n\n const childNodes = EnvProxy.childNodes(this);\n for (let i = 0; i < childNodes.length; i++) {\n parts.push(childNodes[i].textContent);\n }\n\n return parts.join('');\n },\n set: /** @this {Node} */ function(assignedValue) {\n let child;\n while (child = EnvProxy.firstChild(this)) {\n EnvProxy.removeChild(this, child);\n }\n EnvProxy.appendChild(this, EnvProxy.createTextNode(document, assignedValue));\n },\n });\n });\n }\n};\n","import CustomElementInternals from '../../CustomElementInternals.js';\nimport * as Utilities from '../../Utilities.js';\n\n/**\n * @typedef {{\n * before: !function(...(!Node|string)),\n * after: !function(...(!Node|string)),\n * replaceWith: !function(...(!Node|string)),\n * remove: !function(),\n * }}\n */\nlet ChildNodeNativeMethods;\n\n/**\n * @param {!CustomElementInternals} internals\n * @param {!Object} destination\n * @param {!ChildNodeNativeMethods} builtIn\n */\nexport default function(internals, destination, builtIn) {\n /**\n * @param {...(!Node|string)} nodes\n */\n destination['before'] = function(...nodes) {\n // TODO: Fix this for when one of `nodes` is a DocumentFragment!\n const connectedBefore = /** @type {!Array} */ (nodes.filter(node => {\n // DocumentFragments are not connected and will not be added to the list.\n return node instanceof Node && Utilities.isConnected(node);\n }));\n\n builtIn.before.apply(this, nodes);\n\n for (let i = 0; i < connectedBefore.length; i++) {\n internals.disconnectTree(connectedBefore[i]);\n }\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node instanceof Element) {\n internals.connectTree(node);\n }\n }\n }\n };\n\n /**\n * @param {...(!Node|string)} nodes\n */\n destination['after'] = function(...nodes) {\n // TODO: Fix this for when one of `nodes` is a DocumentFragment!\n const connectedBefore = /** @type {!Array} */ (nodes.filter(node => {\n // DocumentFragments are not connected and will not be added to the list.\n return node instanceof Node && Utilities.isConnected(node);\n }));\n\n builtIn.after.apply(this, nodes);\n\n for (let i = 0; i < connectedBefore.length; i++) {\n internals.disconnectTree(connectedBefore[i]);\n }\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node instanceof Element) {\n internals.connectTree(node);\n }\n }\n }\n };\n\n /**\n * @param {...(!Node|string)} nodes\n */\n destination['replaceWith'] = function(...nodes) {\n // TODO: Fix this for when one of `nodes` is a DocumentFragment!\n const connectedBefore = /** @type {!Array} */ (nodes.filter(node => {\n // DocumentFragments are not connected and will not be added to the list.\n return node instanceof Node && Utilities.isConnected(node);\n }));\n\n const wasConnected = Utilities.isConnected(this);\n\n builtIn.replaceWith.apply(this, nodes);\n\n for (let i = 0; i < connectedBefore.length; i++) {\n internals.disconnectTree(connectedBefore[i]);\n }\n\n if (wasConnected) {\n internals.disconnectTree(this);\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node instanceof Element) {\n internals.connectTree(node);\n }\n }\n }\n };\n\n destination['remove'] = function() {\n const wasConnected = Utilities.isConnected(this);\n\n builtIn.remove.call(this);\n\n if (wasConnected) {\n internals.disconnectTree(this);\n }\n };\n};\n","import * as Env from '../Environment.js';\nimport * as EnvProxy from '../EnvironmentProxy.js';\nimport CustomElementInternals from '../CustomElementInternals.js';\nimport CEState from '../CustomElementState.js';\nimport * as Utilities from '../Utilities.js';\n\nimport PatchParentNode from './Interface/ParentNode.js';\nimport PatchChildNode from './Interface/ChildNode.js';\n\n/**\n * @param {!CustomElementInternals} internals\n */\nexport default function(internals) {\n if (Env.Element.attachShadow) {\n Utilities.setPropertyUnchecked(Element.prototype, 'attachShadow',\n /**\n * @this {Element}\n * @param {!{mode: string}} init\n * @return {ShadowRoot}\n */\n function(init) {\n const shadowRoot = EnvProxy.attachShadow(this, init);\n this.__CE_shadowRoot = shadowRoot;\n return shadowRoot;\n });\n } else {\n console.warn('Custom Elements: `Element#attachShadow` was not patched.');\n }\n\n\n function patch_innerHTML(destination, baseDescriptor) {\n Object.defineProperty(destination, 'innerHTML', {\n enumerable: baseDescriptor.enumerable,\n configurable: true,\n get: baseDescriptor.get,\n set: /** @this {Element} */ function(htmlString) {\n const isConnected = Utilities.isConnected(this);\n\n // NOTE: In IE11, when using the native `innerHTML` setter, all nodes\n // that were previously descendants of the context element have all of\n // their children removed as part of the set - the entire subtree is\n // 'disassembled'. This work around walks the subtree *before* using the\n // native setter.\n /** @type {!Array|undefined} */\n let removedElements = undefined;\n if (isConnected) {\n removedElements = [];\n Utilities.walkDeepDescendantElements(this, element => {\n if (element !== this) {\n removedElements.push(element);\n }\n });\n }\n\n baseDescriptor.set.call(this, htmlString);\n\n if (removedElements) {\n for (let i = 0; i < removedElements.length; i++) {\n const element = removedElements[i];\n if (element.__CE_state === CEState.custom) {\n internals.disconnectedCallback(element);\n }\n }\n }\n\n // Only create custom elements if this element's owner document is\n // associated with the registry.\n if (!this.ownerDocument.__CE_hasRegistry) {\n internals.patchTree(this);\n } else {\n internals.patchAndUpgradeTree(this);\n }\n return htmlString;\n },\n });\n }\n\n if (Env.Element.innerHTML && Env.Element.innerHTML.get) {\n patch_innerHTML(Element.prototype, Env.Element.innerHTML);\n } else if (Env.HTMLElement.innerHTML && Env.HTMLElement.innerHTML.get) {\n patch_innerHTML(HTMLElement.prototype, Env.HTMLElement.innerHTML);\n } else {\n // In this case, `innerHTML` has no exposed getter but still exists. Rather\n // than using the environment proxy, we have to get and set it directly.\n\n /** @type {HTMLDivElement} */\n const rawDiv = EnvProxy.createElement(document, 'div');\n\n internals.addPatch(function(element) {\n patch_innerHTML(element, {\n enumerable: true,\n configurable: true,\n // Implements getting `innerHTML` by performing an unpatched `cloneNode`\n // of the element and returning the resulting element's `innerHTML`.\n // TODO: Is this too expensive?\n get: /** @this {Element} */ function() {\n return EnvProxy.cloneNode(this, true).innerHTML;\n },\n // Implements setting `innerHTML` by creating an unpatched element,\n // setting `innerHTML` of that element and replacing the target\n // element's children with those of the unpatched element.\n set: /** @this {Element} */ function(assignedValue) {\n // NOTE: re-route to `content` for `template` elements.\n // We need to do this because `template.appendChild` does not\n // route into `template.content`.\n /** @type {!Node} */\n const content =\n (EnvProxy.localName(this) === 'template')\n ? EnvProxy.content(/** @type {!HTMLTemplateElement} */ (this))\n : this;\n rawDiv.innerHTML = assignedValue;\n\n while (EnvProxy.childNodes(content).length > 0) {\n EnvProxy.removeChild(content, content.childNodes[0]);\n }\n while (EnvProxy.childNodes(rawDiv).length > 0) {\n EnvProxy.appendChild(content, rawDiv.childNodes[0]);\n }\n },\n });\n });\n }\n\n\n Utilities.setPropertyUnchecked(Element.prototype, 'setAttribute',\n /**\n * @this {Element}\n * @param {string} name\n * @param {string} newValue\n */\n function(name, newValue) {\n // Fast path for non-custom elements.\n if (this.__CE_state !== CEState.custom) {\n return EnvProxy.setAttribute(this, name, newValue);\n }\n\n const oldValue = EnvProxy.getAttribute(this, name);\n EnvProxy.setAttribute(this, name, newValue);\n newValue = EnvProxy.getAttribute(this, name);\n internals.attributeChangedCallback(this, name, oldValue, newValue, null);\n });\n\n Utilities.setPropertyUnchecked(Element.prototype, 'setAttributeNS',\n /**\n * @this {Element}\n * @param {?string} namespace\n * @param {string} name\n * @param {string} newValue\n */\n function(namespace, name, newValue) {\n // Fast path for non-custom elements.\n if (this.__CE_state !== CEState.custom) {\n return EnvProxy.setAttributeNS(this, namespace, name, newValue);\n }\n\n const oldValue = EnvProxy.getAttributeNS(this, namespace, name);\n EnvProxy.setAttributeNS(this, namespace, name, newValue);\n newValue = EnvProxy.getAttributeNS(this, namespace, name);\n internals.attributeChangedCallback(this, name, oldValue, newValue, namespace);\n });\n\n Utilities.setPropertyUnchecked(Element.prototype, 'removeAttribute',\n /**\n * @this {Element}\n * @param {string} name\n */\n function(name) {\n // Fast path for non-custom elements.\n if (this.__CE_state !== CEState.custom) {\n return EnvProxy.removeAttribute(this, name);\n }\n\n const oldValue = EnvProxy.getAttribute(this, name);\n EnvProxy.removeAttribute(this, name);\n if (oldValue !== null) {\n internals.attributeChangedCallback(this, name, oldValue, null, null);\n }\n });\n\n Utilities.setPropertyUnchecked(Element.prototype, 'removeAttributeNS',\n /**\n * @this {Element}\n * @param {?string} namespace\n * @param {string} name\n */\n function(namespace, name) {\n // Fast path for non-custom elements.\n if (this.__CE_state !== CEState.custom) {\n return EnvProxy.removeAttributeNS(this, namespace, name);\n }\n\n const oldValue = EnvProxy.getAttributeNS(this, namespace, name);\n EnvProxy.removeAttributeNS(this, namespace, name);\n // In older browsers, `Element#getAttributeNS` may return the empty string\n // instead of null if the attribute does not exist. For details, see;\n // https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttributeNS#Notes\n const newValue = EnvProxy.getAttributeNS(this, namespace, name);\n if (oldValue !== newValue) {\n internals.attributeChangedCallback(this, name, oldValue, newValue, namespace);\n }\n });\n\n\n function patch_insertAdjacentElement(destination, baseMethod) {\n Utilities.setPropertyUnchecked(destination, 'insertAdjacentElement',\n /**\n * @this {Element}\n * @param {string} where\n * @param {!Element} element\n * @return {?Element}\n */\n function(where, element) {\n const wasConnected = Utilities.isConnected(element);\n const insertedElement = /** @type {!Element} */\n (baseMethod.call(this, where, element));\n\n if (wasConnected) {\n internals.disconnectTree(element);\n }\n\n if (Utilities.isConnected(insertedElement)) {\n internals.connectTree(element);\n }\n return insertedElement;\n });\n }\n\n if (Env.HTMLElement['insertAdjacentElement'] && Env.HTMLElement['insertAdjacentElement'].value) {\n patch_insertAdjacentElement(HTMLElement.prototype, Env.HTMLElement['insertAdjacentElement'].value);\n } else if (Env.Element['insertAdjacentElement'] && Env.Element['insertAdjacentElement'].value) {\n patch_insertAdjacentElement(Element.prototype, Env.Element['insertAdjacentElement'].value);\n } else {\n console.warn('Custom Elements: `Element#insertAdjacentElement` was not patched.');\n }\n\n\n PatchParentNode(internals, Element.prototype, {\n prepend: (Env.Element.prepend || {}).value,\n append: (Env.Element.append || {}).value,\n });\n\n PatchChildNode(internals, Element.prototype, {\n before: (Env.Element.before || {}).value,\n after: (Env.Element.after || {}).value,\n replaceWith: (Env.Element.replaceWith || {}).value,\n remove: (Env.Element.remove || {}).value,\n });\n};\n"]} \ No newline at end of file From 377488c37d25168d864db5316e092e98f36572f3 Mon Sep 17 00:00:00 2001 From: Russell Bicknell Date: Mon, 12 Jun 2017 14:13:26 -0700 Subject: [PATCH 09/92] Only capture used descriptors. --- src/DocumentConstructionObserver.js | 3 +- src/Environment.js | 118 +++++++++++++++++++++++----- src/EnvironmentProxy.js | 2 - src/Patch/Element.js | 8 +- src/Patch/HTMLElement.js | 2 +- 5 files changed, 106 insertions(+), 27 deletions(-) diff --git a/src/DocumentConstructionObserver.js b/src/DocumentConstructionObserver.js index f810f32..8982847 100644 --- a/src/DocumentConstructionObserver.js +++ b/src/DocumentConstructionObserver.js @@ -1,3 +1,4 @@ +import * as Env from './Environment.js'; import * as EnvProxy from './EnvironmentProxy.js'; import CustomElementInternals from './CustomElementInternals.js'; @@ -24,7 +25,7 @@ export default class DocumentConstructionObserver { this._internals.patchAndUpgradeTree(this._document); if (EnvProxy.readyState(this._document) === 'loading') { - this._observer = new EnvProxy.MutationObserver(this._handleMutations.bind(this)); + this._observer = new Env.MutationObserver.self(this._handleMutations.bind(this)); // Nodes created by the parser are given to the observer *before* the next // task runs. Inline scripts are run in a new task. This means that the diff --git a/src/Environment.js b/src/Environment.js index dad8a74..628458b 100644 --- a/src/Environment.js +++ b/src/Environment.js @@ -1,19 +1,99 @@ -function getOwnPropertyDescriptors(target) { - const clone = {}; - - const keys = Object.getOwnPropertyNames(target); - for (let i = 0; i < keys.length; i++) { - const key = keys[i]; - clone[key] = Object.getOwnPropertyDescriptor(target, key); - } - - return clone; -} - -export const Document = getOwnPropertyDescriptors(window.Document.prototype); -export const Element = getOwnPropertyDescriptors(window.Element.prototype); -export const HTMLElement = getOwnPropertyDescriptors(window.HTMLElement.prototype); -export const HTMLTemplateElement = getOwnPropertyDescriptors(window.HTMLElement.prototype); -export const MutationObserver = getOwnPropertyDescriptors(window.MutationObserver.prototype); -export const MutationRecord = getOwnPropertyDescriptors(window.MutationRecord.prototype); -export const Node = getOwnPropertyDescriptors(window.Node.prototype); +const getDescriptor = (o, p) => Object.getOwnPropertyDescriptor(o, p); + +const envDocument = window['Document']; +const envDocument_proto = envDocument.prototype; +export const Document = { + self: envDocument, + // Closure's renaming breaks if this property is named `prototype`. + proto: envDocument_proto, + + append: getDescriptor(envDocument_proto, 'append'), + createElement: getDescriptor(envDocument_proto, 'createElement'), + createElementNS: getDescriptor(envDocument_proto, 'createElementNS'), + createTextNode: getDescriptor(envDocument_proto, 'createTextNode'), + importNode: getDescriptor(envDocument_proto, 'importNode'), + prepend: getDescriptor(envDocument_proto, 'prepend'), + readyState: getDescriptor(envDocument_proto, 'readyState'), +}; + +const envElement = window['Element']; +const envElement_proto = envElement.prototype; +export const Element = { + self: envElement, + proto: envElement_proto, + + after: getDescriptor(envElement_proto, 'after'), + append: getDescriptor(envElement_proto, 'append'), + attachShadow: getDescriptor(envElement_proto, 'attachShadow'), + before: getDescriptor(envElement_proto, 'before'), + getAttribute: getDescriptor(envElement_proto, 'getAttribute'), + getAttributeNS: getDescriptor(envElement_proto, 'getAttributeNS'), + innerHTML: getDescriptor(envElement_proto, 'innerHTML'), + insertAdjacentElement: getDescriptor(envElement_proto, 'insertAdjacentElement'), + localName: getDescriptor(envElement_proto, 'localName'), + prepend: getDescriptor(envElement_proto, 'prepend'), + remove: getDescriptor(envElement_proto, 'remove'), + removeAttribute: getDescriptor(envElement_proto, 'removeAttribute'), + removeAttributeNS: getDescriptor(envElement_proto, 'removeAttributeNS'), + replaceWith: getDescriptor(envElement_proto, 'replaceWith'), + setAttribute: getDescriptor(envElement_proto, 'setAttribute'), + setAttributeNS: getDescriptor(envElement_proto, 'setAttributeNS'), +}; + +const envHTMLElement = window['HTMLElement']; +const envHTMLElement_proto = envHTMLElement['prototype']; +export const HTMLElement = { + self: envHTMLElement, + proto: envHTMLElement_proto, + + innerHTML: getDescriptor(envHTMLElement_proto, 'innerHTML'), +}; + +const envHTMLTemplateElement = window['HTMLTemplateElement']; +const envHTMLTemplateElement_proto = envHTMLTemplateElement['prototype']; +export const HTMLTemplateElement = { + self: envHTMLTemplateElement, + proto: envHTMLTemplateElement_proto, + + content: getDescriptor(envHTMLTemplateElement_proto, 'content'), +}; + +const envMutationObserver = window['MutationObserver']; +const envMutationObserver_proto = envMutationObserver['prototype']; +export const MutationObserver = { + self: envMutationObserver, + proto: envMutationObserver_proto, + + disconnect: getDescriptor(envMutationObserver_proto, 'disconnect'), + observe: getDescriptor(envMutationObserver_proto, 'observe'), +}; + +const envMutationRecord = window['MutationRecord']; +const envMutationRecord_proto = envMutationRecord['prototype']; +export const MutationRecord = { + self: envMutationRecord, + proto: envMutationRecord_proto, + + addedNodes: getDescriptor(envMutationRecord_proto, 'addedNodes'), +}; + +const envNode = window['Node']; +const envNode_proto = envNode['prototype']; +export const Node = { + self: envNode, + proto: envNode_proto, + + addEventListener: getDescriptor(envNode_proto, 'addEventListener'), + appendChild: getDescriptor(envNode_proto, 'appendChild'), + childNodes: getDescriptor(envNode_proto, 'childNodes'), + cloneNode: getDescriptor(envNode_proto, 'cloneNode'), + firstChild: getDescriptor(envNode_proto, 'firstChild'), + insertBefore: getDescriptor(envNode_proto, 'insertBefore'), + isConnected: getDescriptor(envNode_proto, 'isConnected'), + nextSibling: getDescriptor(envNode_proto, 'nextSibling'), + nodeType: getDescriptor(envNode_proto, 'nodeType'), + parentNode: getDescriptor(envNode_proto, 'parentNode'), + removeChild: getDescriptor(envNode_proto, 'removeChild'), + replaceChild: getDescriptor(envNode_proto, 'replaceChild'), + textContent: getDescriptor(envNode_proto, 'textContent'), +}; diff --git a/src/EnvironmentProxy.js b/src/EnvironmentProxy.js index 078ad52..4d122e6 100644 --- a/src/EnvironmentProxy.js +++ b/src/EnvironmentProxy.js @@ -53,8 +53,6 @@ export const content = node => contentGetter.call(node); // MutationObserver -export const MutationObserver = method(Env.MutationObserver.constructor); - const observeMethod = method(Env.MutationObserver.observe); export const observe = (mutationObserver, target, options) => observeMethod.call(mutationObserver, target, options); diff --git a/src/Patch/Element.js b/src/Patch/Element.js index 4057282..0e7bf62 100644 --- a/src/Patch/Element.js +++ b/src/Patch/Element.js @@ -225,10 +225,10 @@ export default function(internals) { }); } - if (Env.HTMLElement['insertAdjacentElement'] && Env.HTMLElement['insertAdjacentElement'].value) { - patch_insertAdjacentElement(HTMLElement.prototype, Env.HTMLElement['insertAdjacentElement'].value); - } else if (Env.Element['insertAdjacentElement'] && Env.Element['insertAdjacentElement'].value) { - patch_insertAdjacentElement(Element.prototype, Env.Element['insertAdjacentElement'].value); + if (Env.HTMLElement.insertAdjacentElement && Env.HTMLElement.insertAdjacentElement.value) { + patch_insertAdjacentElement(HTMLElement.prototype, Env.HTMLElement.insertAdjacentElement.value); + } else if (Env.Element.insertAdjacentElement && Env.Element.insertAdjacentElement.value) { + patch_insertAdjacentElement(Element.prototype, Env.Element.insertAdjacentElement.value); } else { console.warn('Custom Elements: `Element#insertAdjacentElement` was not patched.'); } diff --git a/src/Patch/HTMLElement.js b/src/Patch/HTMLElement.js index 7e53056..2b05c4c 100644 --- a/src/Patch/HTMLElement.js +++ b/src/Patch/HTMLElement.js @@ -48,7 +48,7 @@ export default function(internals) { return element; } - HTMLElement.prototype = Env.HTMLElement.constructor.value.prototype; + HTMLElement.prototype = Env.HTMLElement.proto; return HTMLElement; })(); From aca80b2f7477a17f1b02c91a600578e332c2ce04 Mon Sep 17 00:00:00 2001 From: Russell Bicknell Date: Mon, 12 Jun 2017 14:30:11 -0700 Subject: [PATCH 10/92] build --- custom-elements.min.js | 50 +++++++++++++++++++------------------- custom-elements.min.js.map | 2 +- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/custom-elements.min.js b/custom-elements.min.js index 95429c3..ffa09e5 100644 --- a/custom-elements.min.js +++ b/custom-elements.min.js @@ -1,28 +1,28 @@ (function(){ -'use strict';var g=new function(){};function k(b){for(var a={},d=Object.getOwnPropertyNames(b),c=0;c descriptor ? descriptor.get : () => undefined;\nconst method = descriptor => descriptor ? descriptor.value : () => undefined;\n\n// Document\n\nconst createElementMethod = method(Env.Document.createElement);\nexport const createElement = (doc, localName) => createElementMethod.call(doc, localName);\n\nconst createElementNSMethod = method(Env.Document.createElementNS);\nexport const createElementNS = (doc, namespace, qualifiedName) => createElementNSMethod.call(doc, namespace, qualifiedName);\n\nconst createTextNodeMethod = method(Env.Document.createTextNode);\nexport const createTextNode = (doc, localName) => createTextNodeMethod.call(doc, localName);\n\nconst importNodeMethod = method(Env.Document.importNode);\nexport const importNode = (doc, node, deep) => importNodeMethod.call(doc, node, deep);\n\nconst readyStateGetter = getter(Env.Document.readyState);\nexport const readyState = doc => readyStateGetter.call(doc);\n\n// Element\n\nconst attachShadowMethod = method(Env.Element.attachShadow);\nexport const attachShadow = (node, options) => attachShadowMethod.call(node, options);\n\nconst getAttributeMethod = method(Env.Element.getAttribute);\nexport const getAttribute = (node, name) => getAttributeMethod.call(node, name);\n\nconst getAttributeNSMethod = method(Env.Element.getAttributeNS);\nexport const getAttributeNS = (node, ns, name) => getAttributeNSMethod.call(node, ns, name);\n\nconst localNameGetter = getter(Env.Element.localName);\nexport const localName = node => localNameGetter.call(node);\n\nconst removeAttributeMethod = method(Env.Element.removeAttribute);\nexport const removeAttribute = (node, name) => removeAttributeMethod.call(node, name);\n\nconst removeAttributeNSMethod = method(Env.Element.removeAttributeNS);\nexport const removeAttributeNS = (node, ns, name) => removeAttributeNSMethod.call(node, ns, name);\n\nconst setAttributeMethod = method(Env.Element.setAttribute);\nexport const setAttribute = (node, name, value) => setAttributeMethod.call(node, name, value);\n\nconst setAttributeNSMethod = method(Env.Element.setAttributeNS);\nexport const setAttributeNS = (node, ns, name, value) => setAttributeNSMethod.call(node, ns, name, value);\n\n// HTMLTemplateElement\n\nconst contentGetter = getter(Env.HTMLTemplateElement.content);\nexport const content = node => contentGetter.call(node);\n\n// MutationObserver\n\nexport const MutationObserver = method(Env.MutationObserver.constructor);\n\nconst observeMethod = method(Env.MutationObserver.observe);\nexport const observe = (mutationObserver, target, options) => observeMethod.call(mutationObserver, target, options);\n\nconst disconnectMethod = method(Env.MutationObserver.disconnect);\nexport const disconnect = mutationObserver => disconnectMethod.call(mutationObserver);\n\n// MutationRecord\n\nconst addedNodesGetter = getter(Env.MutationRecord.addedNodes);\nexport const addedNodes = node => addedNodesGetter.call(node);\n\n// Node\n\nconst addEventListenerMethod = method(Env.Node.addEventListener);\nexport const addEventListener = (node, type, callback, options) => addEventListenerMethod.call(node, type, callback, options);\n\nconst appendChildMethod = method(Env.Node.appendChild);\nexport const appendChild = (node, deep) => appendChildMethod.call(node, deep);\n\nconst childNodesGetter = getter(Env.Node.childNodes);\nexport const childNodes = node => childNodesGetter.call(node);\n\nconst cloneNodeMethod = method(Env.Node.cloneNode);\nexport const cloneNode = (node, deep) => cloneNodeMethod.call(node, deep);\n\nconst firstChildGetter = getter(Env.Node.firstChild);\nexport const firstChild = node => firstChildGetter.call(node);\n\nconst insertBeforeMethod = method(Env.Node.insertBefore);\nexport const insertBefore = (node, newChild, refChild) => insertBeforeMethod.call(node, newChild, refChild);\n\nconst isConnectedGetter = getter(Env.Node.isConnected);\nexport const isConnected = node => isConnectedGetter.call(node);\n\nconst nextSiblingGetter = getter(Env.Node.nextSibling);\nexport const nextSibling = node => nextSiblingGetter.call(node);\n\nconst nodeTypeGetter = getter(Env.Node.nodeType);\nexport const nodeType = node => nodeTypeGetter.call(node);\n\nconst parentNodeGetter = getter(Env.Node.parentNode);\nexport const parentNode = node => parentNodeGetter.call(node);\n\nconst removeChildMethod = method(Env.Node.removeChild);\nexport const removeChild = (node, deep) => removeChildMethod.call(node, deep);\n\nconst replaceChildMethod = method(Env.Node.replaceChild);\nexport const replaceChild = (node, newChild, oldChild) => replaceChildMethod.call(node, newChild, oldChild);\n","import * as EnvProxy from './EnvironmentProxy.js';\nimport * as Utilities from './Utilities.js';\nimport CEState from './CustomElementState.js';\n\nexport default class CustomElementInternals {\n constructor() {\n /** @type {!Map} */\n this._localNameToDefinition = new Map();\n\n /** @type {!Map} */\n this._constructorToDefinition = new Map();\n\n /** @type {!Array} */\n this._patches = [];\n\n /** @type {boolean} */\n this._hasPatches = false;\n }\n\n /**\n * @param {string} localName\n * @param {!CustomElementDefinition} definition\n */\n setDefinition(localName, definition) {\n this._localNameToDefinition.set(localName, definition);\n this._constructorToDefinition.set(definition.constructor, definition);\n }\n\n /**\n * @param {string} localName\n * @return {!CustomElementDefinition|undefined}\n */\n localNameToDefinition(localName) {\n return this._localNameToDefinition.get(localName);\n }\n\n /**\n * @param {!Function} constructor\n * @return {!CustomElementDefinition|undefined}\n */\n constructorToDefinition(constructor) {\n return this._constructorToDefinition.get(constructor);\n }\n\n /**\n * @param {!function(!Node)} listener\n */\n addPatch(listener) {\n this._hasPatches = true;\n this._patches.push(listener);\n }\n\n /**\n * @param {!Node} node\n */\n patchTree(node) {\n if (!this._hasPatches) return;\n\n Utilities.walkDeepDescendantElements(node, element => this.patch(element));\n }\n\n /**\n * @param {!Node} node\n */\n patch(node) {\n if (!this._hasPatches) return;\n\n if (node.__CE_patched) return;\n node.__CE_patched = true;\n\n for (let i = 0; i < this._patches.length; i++) {\n this._patches[i](node);\n }\n }\n\n /**\n * @param {!Node} root\n */\n connectTree(root) {\n const elements = [];\n\n Utilities.walkDeepDescendantElements(root, element => elements.push(element));\n\n for (let i = 0; i < elements.length; i++) {\n const element = elements[i];\n if (element.__CE_state === CEState.custom) {\n this.connectedCallback(element);\n } else {\n this.upgradeElement(element);\n }\n }\n }\n\n /**\n * @param {!Node} root\n */\n disconnectTree(root) {\n const elements = [];\n\n Utilities.walkDeepDescendantElements(root, element => elements.push(element));\n\n for (let i = 0; i < elements.length; i++) {\n const element = elements[i];\n if (element.__CE_state === CEState.custom) {\n this.disconnectedCallback(element);\n }\n }\n }\n\n /**\n * Upgrades all uncustomized custom elements at and below a root node for\n * which there is a definition. When custom element reaction callbacks are\n * assumed to be called synchronously (which, by the current DOM / HTML spec\n * definitions, they are *not*), callbacks for both elements customized\n * synchronously by the parser and elements being upgraded occur in the same\n * relative order.\n *\n * NOTE: This function, when used to simulate the construction of a tree that\n * is already created but not customized (i.e. by the parser), does *not*\n * prevent the element from reading the 'final' (true) state of the tree. For\n * example, the element, during truly synchronous parsing / construction would\n * see that it contains no children as they have not yet been inserted.\n * However, this function does not modify the tree, the element will\n * (incorrectly) have children. Additionally, self-modification restrictions\n * for custom element constructors imposed by the DOM spec are *not* enforced.\n *\n *\n * The following nested list shows the steps extending down from the HTML\n * spec's parsing section that cause elements to be synchronously created and\n * upgraded:\n *\n * The \"in body\" insertion mode:\n * https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody\n * - Switch on token:\n * .. other cases ..\n * -> Any other start tag\n * - [Insert an HTML element](below) for the token.\n *\n * Insert an HTML element:\n * https://html.spec.whatwg.org/multipage/syntax.html#insert-an-html-element\n * - Insert a foreign element for the token in the HTML namespace:\n * https://html.spec.whatwg.org/multipage/syntax.html#insert-a-foreign-element\n * - Create an element for a token:\n * https://html.spec.whatwg.org/multipage/syntax.html#create-an-element-for-the-token\n * - Will execute script flag is true?\n * - (Element queue pushed to the custom element reactions stack.)\n * - Create an element:\n * https://dom.spec.whatwg.org/#concept-create-element\n * - Sync CE flag is true?\n * - Constructor called.\n * - Self-modification restrictions enforced.\n * - Sync CE flag is false?\n * - (Upgrade reaction enqueued.)\n * - Attributes appended to element.\n * (`attributeChangedCallback` reactions enqueued.)\n * - Will execute script flag is true?\n * - (Element queue popped from the custom element reactions stack.\n * Reactions in the popped stack are invoked.)\n * - (Element queue pushed to the custom element reactions stack.)\n * - Insert the element:\n * https://dom.spec.whatwg.org/#concept-node-insert\n * - Shadow-including descendants are connected. During parsing\n * construction, there are no shadow-*excluding* descendants.\n * However, the constructor may have validly attached a shadow\n * tree to itself and added descendants to that shadow tree.\n * (`connectedCallback` reactions enqueued.)\n * - (Element queue popped from the custom element reactions stack.\n * Reactions in the popped stack are invoked.)\n *\n * @param {!Node} root\n * @param {!Set=} visitedImports\n */\n patchAndUpgradeTree(root, visitedImports = new Set()) {\n const elements = [];\n\n const gatherElements = element => {\n if (EnvProxy.localName(element) === 'link' && EnvProxy.getAttribute(element, 'rel') === 'import') {\n // The HTML Imports polyfill sets a descendant element of the link to\n // the `import` property, specifically this is *not* a Document.\n const importNode = /** @type {?Node} */ (element.import);\n\n if (importNode instanceof Node && importNode.readyState === 'complete') {\n importNode.__CE_isImportDocument = true;\n\n // Connected links are associated with the registry.\n importNode.__CE_hasRegistry = true;\n } else {\n // If this link's import root is not available, its contents can't be\n // walked. Wait for 'load' and walk it when it's ready.\n EnvProxy.addEventListener(element, 'load', () => {\n const importNode = /** @type {!Node} */ (element.import);\n\n if (importNode.__CE_documentLoadHandled) return;\n importNode.__CE_documentLoadHandled = true;\n\n importNode.__CE_isImportDocument = true;\n\n // Connected links are associated with the registry.\n importNode.__CE_hasRegistry = true;\n\n // Clone the `visitedImports` set that was populated sync during\n // the `patchAndUpgradeTree` call that caused this 'load' handler to\n // be added. Then, remove *this* link's import node so that we can\n // walk that import again, even if it was partially walked later\n // during the same `patchAndUpgradeTree` call.\n const clonedVisitedImports = new Set(visitedImports);\n visitedImports.delete(importNode);\n\n this.patchAndUpgradeTree(importNode, visitedImports);\n });\n }\n } else {\n elements.push(element);\n }\n };\n\n // `walkDeepDescendantElements` populates (and internally checks against)\n // `visitedImports` when traversing a loaded import.\n Utilities.walkDeepDescendantElements(root, gatherElements, visitedImports);\n\n if (this._hasPatches) {\n for (let i = 0; i < elements.length; i++) {\n this.patch(elements[i]);\n }\n }\n\n for (let i = 0; i < elements.length; i++) {\n this.upgradeElement(elements[i]);\n }\n }\n\n /**\n * @param {!Element} element\n */\n upgradeElement(element) {\n const currentState = element.__CE_state;\n if (currentState !== undefined) return;\n\n const definition = this.localNameToDefinition(element.localName);\n if (!definition) return;\n\n definition.constructionStack.push(element);\n\n const constructor = definition.constructor;\n try {\n try {\n let result = new (constructor)();\n if (result !== element) {\n throw new Error('The custom element constructor did not produce the element being upgraded.');\n }\n } finally {\n definition.constructionStack.pop();\n }\n } catch (e) {\n element.__CE_state = CEState.failed;\n throw e;\n }\n\n element.__CE_state = CEState.custom;\n element.__CE_definition = definition;\n\n if (definition.attributeChangedCallback) {\n const observedAttributes = definition.observedAttributes;\n for (let i = 0; i < observedAttributes.length; i++) {\n const name = observedAttributes[i];\n const value = EnvProxy.getAttribute(element, name);\n if (value !== null) {\n this.attributeChangedCallback(element, name, null, value, null);\n }\n }\n }\n\n if (Utilities.isConnected(element)) {\n this.connectedCallback(element);\n }\n }\n\n /**\n * @param {!Element} element\n */\n connectedCallback(element) {\n const definition = element.__CE_definition;\n if (definition.connectedCallback) {\n definition.connectedCallback.call(element);\n }\n }\n\n /**\n * @param {!Element} element\n */\n disconnectedCallback(element) {\n const definition = element.__CE_definition;\n if (definition.disconnectedCallback) {\n definition.disconnectedCallback.call(element);\n }\n }\n\n /**\n * @param {!Element} element\n * @param {string} name\n * @param {?string} oldValue\n * @param {?string} newValue\n * @param {?string} namespace\n */\n attributeChangedCallback(element, name, oldValue, newValue, namespace) {\n const definition = element.__CE_definition;\n if (\n definition.attributeChangedCallback &&\n definition.observedAttributes.indexOf(name) > -1\n ) {\n definition.attributeChangedCallback.call(element, name, oldValue, newValue, namespace);\n }\n }\n}\n","import * as EnvProxy from './EnvironmentProxy.js';\n\nconst reservedTagList = new Set([\n 'annotation-xml',\n 'color-profile',\n 'font-face',\n 'font-face-src',\n 'font-face-uri',\n 'font-face-format',\n 'font-face-name',\n 'missing-glyph',\n]);\n\n/**\n * @param {string} localName\n * @returns {boolean}\n */\nexport function isValidCustomElementName(localName) {\n const reserved = reservedTagList.has(localName);\n const validForm = /^[a-z][.0-9_a-z]*-[\\-.0-9_a-z]*$/.test(localName);\n return !reserved && validForm;\n}\n\n/**\n * @private\n * @param {!Node} node\n * @return {boolean}\n */\nexport function isConnected(node) {\n // Use `Node#isConnected`, if defined.\n const nativeValue = EnvProxy.isConnected(node);\n if (nativeValue !== undefined) {\n return nativeValue;\n }\n\n /** @type {?Node|undefined} */\n let current = node;\n while (current && !(current.__CE_isImportDocument || current instanceof Document)) {\n current = EnvProxy.parentNode(current) || (window.ShadowRoot && current instanceof ShadowRoot ? current.host : undefined);\n }\n return !!(current && (current.__CE_isImportDocument || current instanceof Document));\n}\n\n/**\n * @param {!Node} root\n * @param {!Node} start\n * @return {?Node}\n */\nfunction nextSiblingOrAncestorSibling(root, start) {\n let node = start;\n while (node && node !== root && !EnvProxy.nextSibling(node)) {\n node = EnvProxy.parentNode(node);\n }\n return (!node || node === root) ? null : EnvProxy.nextSibling(node);\n}\n\n/**\n * @param {!Node} root\n * @param {!Node} start\n * @return {?Node}\n */\nfunction nextNode(root, start) {\n return EnvProxy.firstChild(start) || nextSiblingOrAncestorSibling(root, start);\n}\n\n/**\n * @param {!Node} root\n * @param {!function(!Element)} callback\n * @param {!Set=} visitedImports\n */\nexport function walkDeepDescendantElements(root, callback, visitedImports = new Set()) {\n let node = root;\n while (node) {\n if (EnvProxy.nodeType(node) === Node.ELEMENT_NODE) {\n const element = /** @type {!Element} */(node);\n\n callback(element);\n\n const localName = EnvProxy.localName(element);\n if (localName === 'link' && EnvProxy.getAttribute(element, 'rel') === 'import') {\n // If this import (polyfilled or not) has it's root node available,\n // walk it.\n const importNode = /** @type {!Node} */ (element.import);\n if (importNode instanceof Node && !visitedImports.has(importNode)) {\n // Prevent multiple walks of the same import root.\n visitedImports.add(importNode);\n\n for (let child = EnvProxy.firstChild(importNode); child; child = EnvProxy.nextSibling(child)) {\n walkDeepDescendantElements(child, callback, visitedImports);\n }\n }\n\n // Ignore descendants of import links to prevent attempting to walk the\n // elements created by the HTML Imports polyfill that we just walked\n // above.\n node = nextSiblingOrAncestorSibling(root, element);\n continue;\n } else if (localName === 'template') {\n // Ignore descendants of templates. There shouldn't be any descendants\n // because they will be moved into `.content` during construction in\n // browsers that support template but, in case they exist and are still\n // waiting to be moved by a polyfill, they will be ignored.\n node = nextSiblingOrAncestorSibling(root, element);\n continue;\n }\n\n // Walk shadow roots.\n const shadowRoot = element.__CE_shadowRoot;\n if (shadowRoot) {\n for (let child = EnvProxy.firstChild(shadowRoot); child; child = EnvProxy.nextSibling(child)) {\n walkDeepDescendantElements(child, callback, visitedImports);\n }\n }\n }\n\n node = nextNode(root, node);\n }\n}\n\n/**\n * Used to suppress Closure's \"Modifying the prototype is only allowed if the\n * constructor is in the same scope\" warning without using\n * `@suppress {newCheckTypes, duplicate}` because `newCheckTypes` is too broad.\n *\n * @param {!Object} destination\n * @param {string} name\n * @param {*} value\n */\nexport function setPropertyUnchecked(destination, name, value) {\n destination[name] = value;\n}\n","/**\n * @enum {number}\n */\nconst CustomElementState = {\n custom: 1,\n failed: 2,\n};\n\nexport default CustomElementState;\n","import * as EnvProxy from './EnvironmentProxy.js';\nimport CustomElementInternals from './CustomElementInternals.js';\n\nexport default class DocumentConstructionObserver {\n constructor(internals, doc) {\n /**\n * @type {!CustomElementInternals}\n */\n this._internals = internals;\n\n /**\n * @type {!Document}\n */\n this._document = doc;\n\n /**\n * @type {MutationObserver|undefined}\n */\n this._observer = undefined;\n\n\n // Simulate tree construction for all currently accessible nodes in the\n // document.\n this._internals.patchAndUpgradeTree(this._document);\n\n if (EnvProxy.readyState(this._document) === 'loading') {\n this._observer = new EnvProxy.MutationObserver(this._handleMutations.bind(this));\n\n // Nodes created by the parser are given to the observer *before* the next\n // task runs. Inline scripts are run in a new task. This means that the\n // observer will be able to handle the newly parsed nodes before the inline\n // script is run.\n EnvProxy.observe(this._observer, this._document, {\n childList: true,\n subtree: true,\n });\n }\n }\n\n disconnect() {\n if (this._observer) {\n EnvProxy.disconnect(this._observer);\n }\n }\n\n /**\n * @param {!Array} mutations\n */\n _handleMutations(mutations) {\n // Once the document's `readyState` is 'interactive' or 'complete', all new\n // nodes created within that document will be the result of script and\n // should be handled by patching.\n const readyState = EnvProxy.readyState(this._document);\n if (readyState === 'interactive' || readyState === 'complete') {\n this.disconnect();\n }\n\n for (let i = 0; i < mutations.length; i++) {\n const addedNodes = EnvProxy.addedNodes(mutations[i]);\n for (let j = 0; j < addedNodes.length; j++) {\n const node = addedNodes[j];\n this._internals.patchAndUpgradeTree(node);\n }\n }\n }\n}\n","/**\n * @template T\n */\nexport default class Deferred {\n constructor() {\n /**\n * @private\n * @type {T|undefined}\n */\n this._value = undefined;\n\n /**\n * @private\n * @type {Function|undefined}\n */\n this._resolve = undefined;\n\n /**\n * @private\n * @type {!Promise}\n */\n this._promise = new Promise(resolve => {\n this._resolve = resolve;\n\n if (this._value) {\n resolve(this._value);\n }\n });\n }\n\n /**\n * @param {T} value\n */\n resolve(value) {\n if (this._value) {\n throw new Error('Already resolved.');\n }\n\n this._value = value;\n\n if (this._resolve) {\n this._resolve(value);\n }\n }\n\n /**\n * @return {!Promise}\n */\n toPromise() {\n return this._promise;\n }\n}\n","import CustomElementInternals from './CustomElementInternals.js';\nimport DocumentConstructionObserver from './DocumentConstructionObserver.js';\nimport Deferred from './Deferred.js';\nimport * as Utilities from './Utilities.js';\n\n/**\n * @unrestricted\n */\nexport default class CustomElementRegistry {\n\n /**\n * @param {!CustomElementInternals} internals\n */\n constructor(internals) {\n /**\n * @private\n * @type {boolean}\n */\n this._elementDefinitionIsRunning = false;\n\n /**\n * @private\n * @type {!CustomElementInternals}\n */\n this._internals = internals;\n\n /**\n * @private\n * @type {!Map>}\n */\n this._whenDefinedDeferred = new Map();\n\n /**\n * The default flush callback triggers the document walk synchronously.\n * @private\n * @type {!Function}\n */\n this._flushCallback = fn => fn();\n\n /**\n * @private\n * @type {boolean}\n */\n this._flushPending = false;\n\n /**\n * @private\n * @type {!Array}\n */\n this._unflushedLocalNames = [];\n\n /**\n * @private\n * @type {!DocumentConstructionObserver}\n */\n this._documentConstructionObserver = new DocumentConstructionObserver(internals, document);\n }\n\n /**\n * @param {string} localName\n * @param {!Function} constructor\n */\n define(localName, constructor) {\n if (!(constructor instanceof Function)) {\n throw new TypeError('Custom element constructors must be functions.');\n }\n\n if (!Utilities.isValidCustomElementName(localName)) {\n throw new SyntaxError(`The element name '${localName}' is not valid.`);\n }\n\n if (this._internals.localNameToDefinition(localName)) {\n throw new Error(`A custom element with name '${localName}' has already been defined.`);\n }\n\n if (this._elementDefinitionIsRunning) {\n throw new Error('A custom element is already being defined.');\n }\n this._elementDefinitionIsRunning = true;\n\n let connectedCallback;\n let disconnectedCallback;\n let adoptedCallback;\n let attributeChangedCallback;\n let observedAttributes;\n try {\n /** @type {!Object} */\n const prototype = constructor.prototype;\n if (!(prototype instanceof Object)) {\n throw new TypeError('The custom element constructor\\'s prototype is not an object.');\n }\n\n function getCallback(name) {\n const callbackValue = prototype[name];\n if (callbackValue !== undefined && !(callbackValue instanceof Function)) {\n throw new Error(`The '${name}' callback must be a function.`);\n }\n return callbackValue;\n }\n\n connectedCallback = getCallback('connectedCallback');\n disconnectedCallback = getCallback('disconnectedCallback');\n adoptedCallback = getCallback('adoptedCallback');\n attributeChangedCallback = getCallback('attributeChangedCallback');\n observedAttributes = constructor['observedAttributes'] || [];\n } catch (e) {\n return;\n } finally {\n this._elementDefinitionIsRunning = false;\n }\n\n const definition = {\n localName,\n constructor,\n connectedCallback,\n disconnectedCallback,\n adoptedCallback,\n attributeChangedCallback,\n observedAttributes,\n constructionStack: [],\n };\n\n this._internals.setDefinition(localName, definition);\n\n this._unflushedLocalNames.push(localName);\n\n // If we've already called the flush callback and it hasn't called back yet,\n // don't call it again.\n if (!this._flushPending) {\n this._flushPending = true;\n this._flushCallback(() => this._flush());\n }\n }\n\n _flush() {\n // If no new definitions were defined, don't attempt to flush. This could\n // happen if a flush callback keeps the function it is given and calls it\n // multiple times.\n if (this._flushPending === false) return;\n\n this._flushPending = false;\n this._internals.patchAndUpgradeTree(document);\n\n while (this._unflushedLocalNames.length > 0) {\n const localName = this._unflushedLocalNames.shift();\n const deferred = this._whenDefinedDeferred.get(localName);\n if (deferred) {\n deferred.resolve(undefined);\n }\n }\n }\n\n /**\n * @param {string} localName\n * @return {Function|undefined}\n */\n get(localName) {\n const definition = this._internals.localNameToDefinition(localName);\n if (definition) {\n return definition.constructor;\n }\n\n return undefined;\n }\n\n /**\n * @param {string} localName\n * @return {!Promise}\n */\n whenDefined(localName) {\n if (!Utilities.isValidCustomElementName(localName)) {\n return Promise.reject(new SyntaxError(`'${localName}' is not a valid custom element name.`));\n }\n\n const prior = this._whenDefinedDeferred.get(localName);\n if (prior) {\n return prior.toPromise();\n }\n\n const deferred = new Deferred();\n this._whenDefinedDeferred.set(localName, deferred);\n\n const definition = this._internals.localNameToDefinition(localName);\n // Resolve immediately only if the given local name has a definition *and*\n // the full document walk to upgrade elements with that local name has\n // already happened.\n if (definition && this._unflushedLocalNames.indexOf(localName) === -1) {\n deferred.resolve(undefined);\n }\n\n return deferred.toPromise();\n }\n\n polyfillWrapFlushCallback(outer) {\n this._documentConstructionObserver.disconnect();\n const inner = this._flushCallback;\n this._flushCallback = flush => outer(() => inner(flush));\n }\n}\n\n// Closure compiler exports.\nwindow['CustomElementRegistry'] = CustomElementRegistry;\nCustomElementRegistry.prototype['define'] = CustomElementRegistry.prototype.define;\nCustomElementRegistry.prototype['get'] = CustomElementRegistry.prototype.get;\nCustomElementRegistry.prototype['whenDefined'] = CustomElementRegistry.prototype.whenDefined;\nCustomElementRegistry.prototype['polyfillWrapFlushCallback'] = CustomElementRegistry.prototype.polyfillWrapFlushCallback;\n","import * as Env from '../Environment.js';\nimport * as EnvProxy from '../EnvironmentProxy.js';\nimport CustomElementInternals from '../CustomElementInternals.js';\nimport CEState from '../CustomElementState.js';\nimport AlreadyConstructedMarker from '../AlreadyConstructedMarker.js';\n\n/**\n * @param {!CustomElementInternals} internals\n */\nexport default function(internals) {\n window['HTMLElement'] = (function() {\n /**\n * @type {function(new: HTMLElement): !HTMLElement}\n */\n function HTMLElement() {\n // This should really be `new.target` but `new.target` can't be emulated\n // in ES5. Assuming the user keeps the default value of the constructor's\n // prototype's `constructor` property, this is equivalent.\n /** @type {!Function} */\n const constructor = this.constructor;\n\n const definition = internals.constructorToDefinition(constructor);\n if (!definition) {\n throw new Error('The custom element being constructed was not registered with `customElements`.');\n }\n\n const constructionStack = definition.constructionStack;\n\n if (constructionStack.length === 0) {\n const element = EnvProxy.createElement(document, definition.localName);\n Object.setPrototypeOf(element, constructor.prototype);\n element.__CE_state = CEState.custom;\n element.__CE_definition = definition;\n internals.patch(element);\n return element;\n }\n\n const lastIndex = constructionStack.length - 1;\n const element = constructionStack[lastIndex];\n if (element === AlreadyConstructedMarker) {\n throw new Error('The HTMLElement constructor was either called reentrantly for this constructor or called multiple times.');\n }\n constructionStack[lastIndex] = AlreadyConstructedMarker;\n\n Object.setPrototypeOf(element, constructor.prototype);\n internals.patch(/** @type {!HTMLElement} */ (element));\n\n return element;\n }\n\n HTMLElement.prototype = Env.HTMLElement.constructor.value.prototype;\n\n return HTMLElement;\n })();\n};\n","/**\n * @license\n * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n */\n\nimport CustomElementInternals from './CustomElementInternals.js';\nimport CustomElementRegistry from './CustomElementRegistry.js';\n\nimport PatchHTMLElement from './Patch/HTMLElement.js';\nimport PatchDocument from './Patch/Document.js';\nimport PatchNode from './Patch/Node.js';\nimport PatchElement from './Patch/Element.js';\n\nconst priorCustomElements = window['customElements'];\n\nif (!priorCustomElements ||\n priorCustomElements['forcePolyfill'] ||\n (typeof priorCustomElements['define'] != 'function') ||\n (typeof priorCustomElements['get'] != 'function')) {\n /** @type {!CustomElementInternals} */\n const internals = new CustomElementInternals();\n\n PatchHTMLElement(internals);\n PatchDocument(internals);\n PatchNode(internals);\n PatchElement(internals);\n\n // The main document is always associated with the registry.\n document.__CE_hasRegistry = true;\n\n /** @type {!CustomElementRegistry} */\n const customElements = new CustomElementRegistry(internals);\n\n Object.defineProperty(window, 'customElements', {\n configurable: true,\n enumerable: true,\n value: customElements,\n });\n}\n","import CustomElementInternals from '../../CustomElementInternals.js';\nimport * as Utilities from '../../Utilities.js';\n\n/**\n * @typedef {{\n * prepend: !function(...(!Node|string)),\n * append: !function(...(!Node|string)),\n * }}\n */\nlet ParentNodeNativeMethods;\n\n/**\n * @param {!CustomElementInternals} internals\n * @param {!Object} destination\n * @param {!ParentNodeNativeMethods} builtIn\n */\nexport default function(internals, destination, builtIn) {\n /**\n * @param {...(!Node|string)} nodes\n */\n destination['prepend'] = function(...nodes) {\n // TODO: Fix this for when one of `nodes` is a DocumentFragment!\n const connectedBefore = /** @type {!Array} */ (nodes.filter(node => {\n // DocumentFragments are not connected and will not be added to the list.\n return node instanceof Node && Utilities.isConnected(node);\n }));\n\n builtIn.prepend.apply(this, nodes);\n\n for (let i = 0; i < connectedBefore.length; i++) {\n internals.disconnectTree(connectedBefore[i]);\n }\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node instanceof Element) {\n internals.connectTree(node);\n }\n }\n }\n };\n\n /**\n * @param {...(!Node|string)} nodes\n */\n destination['append'] = function(...nodes) {\n // TODO: Fix this for when one of `nodes` is a DocumentFragment!\n const connectedBefore = /** @type {!Array} */ (nodes.filter(node => {\n // DocumentFragments are not connected and will not be added to the list.\n return node instanceof Node && Utilities.isConnected(node);\n }));\n\n builtIn.append.apply(this, nodes);\n\n for (let i = 0; i < connectedBefore.length; i++) {\n internals.disconnectTree(connectedBefore[i]);\n }\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node instanceof Element) {\n internals.connectTree(node);\n }\n }\n }\n };\n};\n","import * as Env from '../Environment.js';\nimport * as EnvProxy from '../EnvironmentProxy.js';\nimport CustomElementInternals from '../CustomElementInternals.js';\nimport * as Utilities from '../Utilities.js';\n\nimport PatchParentNode from './Interface/ParentNode.js';\n\n/**\n * @param {!CustomElementInternals} internals\n */\nexport default function(internals) {\n Utilities.setPropertyUnchecked(Document.prototype, 'createElement',\n /**\n * @this {Document}\n * @param {string} localName\n * @return {!Element}\n */\n function(localName) {\n // Only create custom elements if this document is associated with the registry.\n if (this.__CE_hasRegistry) {\n const definition = internals.localNameToDefinition(localName);\n if (definition) {\n return new (definition.constructor)();\n }\n }\n\n const result = /** @type {!Element} */\n (EnvProxy.createElement(this, localName));\n internals.patch(result);\n return result;\n });\n\n Utilities.setPropertyUnchecked(Document.prototype, 'importNode',\n /**\n * @this {Document}\n * @param {!Node} node\n * @param {boolean=} deep\n * @return {!Node}\n */\n function(node, deep) {\n const clone = EnvProxy.importNode(this, node, deep);\n // Only create custom elements if this document is associated with the registry.\n if (!this.__CE_hasRegistry) {\n internals.patchTree(clone);\n } else {\n internals.patchAndUpgradeTree(clone);\n }\n return clone;\n });\n\n const NS_HTML = \"http://www.w3.org/1999/xhtml\";\n\n Utilities.setPropertyUnchecked(Document.prototype, 'createElementNS',\n /**\n * @this {Document}\n * @param {?string} namespace\n * @param {string} localName\n * @return {!Element}\n */\n function(namespace, localName) {\n // Only create custom elements if this document is associated with the registry.\n if (this.__CE_hasRegistry && (namespace === null || namespace === NS_HTML)) {\n const definition = internals.localNameToDefinition(localName);\n if (definition) {\n return new (definition.constructor)();\n }\n }\n\n const result = /** @type {!Element} */\n (EnvProxy.createElementNS(this, namespace, localName));\n internals.patch(result);\n return result;\n });\n\n PatchParentNode(internals, Document.prototype, {\n prepend: (Env.Document.prepend || {}).value,\n append: (Env.Document.append || {}).value,\n });\n};\n","import * as Env from '../Environment.js';\nimport * as EnvProxy from '../EnvironmentProxy.js';\nimport CustomElementInternals from '../CustomElementInternals.js';\nimport * as Utilities from '../Utilities.js';\n\n/**\n * @param {!CustomElementInternals} internals\n */\nexport default function(internals) {\n // `Node#nodeValue` is implemented on `Attr`.\n // `Node#textContent` is implemented on `Attr`, `Element`.\n\n Utilities.setPropertyUnchecked(Node.prototype, 'insertBefore',\n /**\n * @this {Node}\n * @param {!Node} node\n * @param {?Node} refNode\n * @return {!Node}\n */\n function(node, refNode) {\n if (node instanceof DocumentFragment) {\n const insertedNodes = Array.prototype.slice.apply(EnvProxy.childNodes(node));\n const nativeResult = EnvProxy.insertBefore(this, node, refNode);\n\n // DocumentFragments can't be connected, so `disconnectTree` will never\n // need to be called on a DocumentFragment's children after inserting it.\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < insertedNodes.length; i++) {\n internals.connectTree(insertedNodes[i]);\n }\n }\n\n return nativeResult;\n }\n\n const nodeWasConnected = Utilities.isConnected(node);\n const nativeResult = EnvProxy.insertBefore(this, node, refNode);\n\n if (nodeWasConnected) {\n internals.disconnectTree(node);\n }\n\n if (Utilities.isConnected(this)) {\n internals.connectTree(node);\n }\n\n return nativeResult;\n });\n\n Utilities.setPropertyUnchecked(Node.prototype, 'appendChild',\n /**\n * @this {Node}\n * @param {!Node} node\n * @return {!Node}\n */\n function(node) {\n if (node instanceof DocumentFragment) {\n const insertedNodes = Array.prototype.slice.apply(EnvProxy.childNodes(node));\n const nativeResult = EnvProxy.appendChild(this, node);\n\n // DocumentFragments can't be connected, so `disconnectTree` will never\n // need to be called on a DocumentFragment's children after inserting it.\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < insertedNodes.length; i++) {\n internals.connectTree(insertedNodes[i]);\n }\n }\n\n return nativeResult;\n }\n\n const nodeWasConnected = Utilities.isConnected(node);\n const nativeResult = EnvProxy.appendChild(this, node);\n\n if (nodeWasConnected) {\n internals.disconnectTree(node);\n }\n\n if (Utilities.isConnected(this)) {\n internals.connectTree(node);\n }\n\n return nativeResult;\n });\n\n Utilities.setPropertyUnchecked(Node.prototype, 'cloneNode',\n /**\n * @this {Node}\n * @param {boolean=} deep\n * @return {!Node}\n */\n function(deep) {\n const clone = EnvProxy.cloneNode(this, deep);\n // Only create custom elements if this element's owner document is\n // associated with the registry.\n if (!this.ownerDocument.__CE_hasRegistry) {\n internals.patchTree(clone);\n } else {\n internals.patchAndUpgradeTree(clone);\n }\n return clone;\n });\n\n Utilities.setPropertyUnchecked(Node.prototype, 'removeChild',\n /**\n * @this {Node}\n * @param {!Node} node\n * @return {!Node}\n */\n function(node) {\n const nodeWasConnected = Utilities.isConnected(node);\n const nativeResult = EnvProxy.removeChild(this, node);\n\n if (nodeWasConnected) {\n internals.disconnectTree(node);\n }\n\n return nativeResult;\n });\n\n Utilities.setPropertyUnchecked(Node.prototype, 'replaceChild',\n /**\n * @this {Node}\n * @param {!Node} nodeToInsert\n * @param {!Node} nodeToRemove\n * @return {!Node}\n */\n function(nodeToInsert, nodeToRemove) {\n if (nodeToInsert instanceof DocumentFragment) {\n const insertedNodes = Array.prototype.slice.apply(EnvProxy.childNodes(nodeToInsert));\n const nativeResult = EnvProxy.replaceChild(this, nodeToInsert, nodeToRemove);\n\n // DocumentFragments can't be connected, so `disconnectTree` will never\n // need to be called on a DocumentFragment's children after inserting it.\n\n if (Utilities.isConnected(this)) {\n internals.disconnectTree(nodeToRemove);\n for (let i = 0; i < insertedNodes.length; i++) {\n internals.connectTree(insertedNodes[i]);\n }\n }\n\n return nativeResult;\n }\n\n const nodeToInsertWasConnected = Utilities.isConnected(nodeToInsert);\n const nativeResult = EnvProxy.replaceChild(this, nodeToInsert, nodeToRemove);\n const thisIsConnected = Utilities.isConnected(this);\n\n if (thisIsConnected) {\n internals.disconnectTree(nodeToRemove);\n }\n\n if (nodeToInsertWasConnected) {\n internals.disconnectTree(nodeToInsert);\n }\n\n if (thisIsConnected) {\n internals.connectTree(nodeToInsert);\n }\n\n return nativeResult;\n });\n\n\n function patch_textContent(destination, baseDescriptor) {\n Object.defineProperty(destination, 'textContent', {\n enumerable: baseDescriptor.enumerable,\n configurable: true,\n get: baseDescriptor.get,\n set: /** @this {Node} */ function(assignedValue) {\n // If this is a text node then there are no nodes to disconnect.\n if (this.nodeType === Node.TEXT_NODE) {\n baseDescriptor.set.call(this, assignedValue);\n return;\n }\n\n let removedNodes = undefined;\n // Checking for `firstChild` is faster than reading `childNodes.length`\n // to compare with 0.\n if (EnvProxy.firstChild(this)) {\n // Using `childNodes` is faster than `children`, even though we only\n // care about elements.\n const childNodes = EnvProxy.childNodes(this);\n const childNodesLength = childNodes.length;\n if (childNodesLength > 0 && Utilities.isConnected(this)) {\n // Copying an array by iterating is faster than using slice.\n removedNodes = new Array(childNodesLength);\n for (let i = 0; i < childNodesLength; i++) {\n removedNodes[i] = childNodes[i];\n }\n }\n }\n\n baseDescriptor.set.call(this, assignedValue);\n\n if (removedNodes) {\n for (let i = 0; i < removedNodes.length; i++) {\n internals.disconnectTree(removedNodes[i]);\n }\n }\n },\n });\n }\n\n if (Env.Node.textContent && Env.Node.textContent.get) {\n patch_textContent(Node.prototype, Env.Node.textContent);\n } else {\n internals.addPatch(function(element) {\n patch_textContent(element, {\n enumerable: true,\n configurable: true,\n // NOTE: This implementation of the `textContent` getter assumes that\n // text nodes' `textContent` getter will not be patched.\n get: /** @this {Node} */ function() {\n /** @type {!Array} */\n const parts = [];\n\n const childNodes = EnvProxy.childNodes(this);\n for (let i = 0; i < childNodes.length; i++) {\n parts.push(childNodes[i].textContent);\n }\n\n return parts.join('');\n },\n set: /** @this {Node} */ function(assignedValue) {\n let child;\n while (child = EnvProxy.firstChild(this)) {\n EnvProxy.removeChild(this, child);\n }\n EnvProxy.appendChild(this, EnvProxy.createTextNode(document, assignedValue));\n },\n });\n });\n }\n};\n","import CustomElementInternals from '../../CustomElementInternals.js';\nimport * as Utilities from '../../Utilities.js';\n\n/**\n * @typedef {{\n * before: !function(...(!Node|string)),\n * after: !function(...(!Node|string)),\n * replaceWith: !function(...(!Node|string)),\n * remove: !function(),\n * }}\n */\nlet ChildNodeNativeMethods;\n\n/**\n * @param {!CustomElementInternals} internals\n * @param {!Object} destination\n * @param {!ChildNodeNativeMethods} builtIn\n */\nexport default function(internals, destination, builtIn) {\n /**\n * @param {...(!Node|string)} nodes\n */\n destination['before'] = function(...nodes) {\n // TODO: Fix this for when one of `nodes` is a DocumentFragment!\n const connectedBefore = /** @type {!Array} */ (nodes.filter(node => {\n // DocumentFragments are not connected and will not be added to the list.\n return node instanceof Node && Utilities.isConnected(node);\n }));\n\n builtIn.before.apply(this, nodes);\n\n for (let i = 0; i < connectedBefore.length; i++) {\n internals.disconnectTree(connectedBefore[i]);\n }\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node instanceof Element) {\n internals.connectTree(node);\n }\n }\n }\n };\n\n /**\n * @param {...(!Node|string)} nodes\n */\n destination['after'] = function(...nodes) {\n // TODO: Fix this for when one of `nodes` is a DocumentFragment!\n const connectedBefore = /** @type {!Array} */ (nodes.filter(node => {\n // DocumentFragments are not connected and will not be added to the list.\n return node instanceof Node && Utilities.isConnected(node);\n }));\n\n builtIn.after.apply(this, nodes);\n\n for (let i = 0; i < connectedBefore.length; i++) {\n internals.disconnectTree(connectedBefore[i]);\n }\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node instanceof Element) {\n internals.connectTree(node);\n }\n }\n }\n };\n\n /**\n * @param {...(!Node|string)} nodes\n */\n destination['replaceWith'] = function(...nodes) {\n // TODO: Fix this for when one of `nodes` is a DocumentFragment!\n const connectedBefore = /** @type {!Array} */ (nodes.filter(node => {\n // DocumentFragments are not connected and will not be added to the list.\n return node instanceof Node && Utilities.isConnected(node);\n }));\n\n const wasConnected = Utilities.isConnected(this);\n\n builtIn.replaceWith.apply(this, nodes);\n\n for (let i = 0; i < connectedBefore.length; i++) {\n internals.disconnectTree(connectedBefore[i]);\n }\n\n if (wasConnected) {\n internals.disconnectTree(this);\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node instanceof Element) {\n internals.connectTree(node);\n }\n }\n }\n };\n\n destination['remove'] = function() {\n const wasConnected = Utilities.isConnected(this);\n\n builtIn.remove.call(this);\n\n if (wasConnected) {\n internals.disconnectTree(this);\n }\n };\n};\n","import * as Env from '../Environment.js';\nimport * as EnvProxy from '../EnvironmentProxy.js';\nimport CustomElementInternals from '../CustomElementInternals.js';\nimport CEState from '../CustomElementState.js';\nimport * as Utilities from '../Utilities.js';\n\nimport PatchParentNode from './Interface/ParentNode.js';\nimport PatchChildNode from './Interface/ChildNode.js';\n\n/**\n * @param {!CustomElementInternals} internals\n */\nexport default function(internals) {\n if (Env.Element.attachShadow) {\n Utilities.setPropertyUnchecked(Element.prototype, 'attachShadow',\n /**\n * @this {Element}\n * @param {!{mode: string}} init\n * @return {ShadowRoot}\n */\n function(init) {\n const shadowRoot = EnvProxy.attachShadow(this, init);\n this.__CE_shadowRoot = shadowRoot;\n return shadowRoot;\n });\n } else {\n console.warn('Custom Elements: `Element#attachShadow` was not patched.');\n }\n\n\n function patch_innerHTML(destination, baseDescriptor) {\n Object.defineProperty(destination, 'innerHTML', {\n enumerable: baseDescriptor.enumerable,\n configurable: true,\n get: baseDescriptor.get,\n set: /** @this {Element} */ function(htmlString) {\n const isConnected = Utilities.isConnected(this);\n\n // NOTE: In IE11, when using the native `innerHTML` setter, all nodes\n // that were previously descendants of the context element have all of\n // their children removed as part of the set - the entire subtree is\n // 'disassembled'. This work around walks the subtree *before* using the\n // native setter.\n /** @type {!Array|undefined} */\n let removedElements = undefined;\n if (isConnected) {\n removedElements = [];\n Utilities.walkDeepDescendantElements(this, element => {\n if (element !== this) {\n removedElements.push(element);\n }\n });\n }\n\n baseDescriptor.set.call(this, htmlString);\n\n if (removedElements) {\n for (let i = 0; i < removedElements.length; i++) {\n const element = removedElements[i];\n if (element.__CE_state === CEState.custom) {\n internals.disconnectedCallback(element);\n }\n }\n }\n\n // Only create custom elements if this element's owner document is\n // associated with the registry.\n if (!this.ownerDocument.__CE_hasRegistry) {\n internals.patchTree(this);\n } else {\n internals.patchAndUpgradeTree(this);\n }\n return htmlString;\n },\n });\n }\n\n if (Env.Element.innerHTML && Env.Element.innerHTML.get) {\n patch_innerHTML(Element.prototype, Env.Element.innerHTML);\n } else if (Env.HTMLElement.innerHTML && Env.HTMLElement.innerHTML.get) {\n patch_innerHTML(HTMLElement.prototype, Env.HTMLElement.innerHTML);\n } else {\n // In this case, `innerHTML` has no exposed getter but still exists. Rather\n // than using the environment proxy, we have to get and set it directly.\n\n /** @type {HTMLDivElement} */\n const rawDiv = EnvProxy.createElement(document, 'div');\n\n internals.addPatch(function(element) {\n patch_innerHTML(element, {\n enumerable: true,\n configurable: true,\n // Implements getting `innerHTML` by performing an unpatched `cloneNode`\n // of the element and returning the resulting element's `innerHTML`.\n // TODO: Is this too expensive?\n get: /** @this {Element} */ function() {\n return EnvProxy.cloneNode(this, true).innerHTML;\n },\n // Implements setting `innerHTML` by creating an unpatched element,\n // setting `innerHTML` of that element and replacing the target\n // element's children with those of the unpatched element.\n set: /** @this {Element} */ function(assignedValue) {\n // NOTE: re-route to `content` for `template` elements.\n // We need to do this because `template.appendChild` does not\n // route into `template.content`.\n /** @type {!Node} */\n const content =\n (EnvProxy.localName(this) === 'template')\n ? EnvProxy.content(/** @type {!HTMLTemplateElement} */ (this))\n : this;\n rawDiv.innerHTML = assignedValue;\n\n while (EnvProxy.childNodes(content).length > 0) {\n EnvProxy.removeChild(content, content.childNodes[0]);\n }\n while (EnvProxy.childNodes(rawDiv).length > 0) {\n EnvProxy.appendChild(content, rawDiv.childNodes[0]);\n }\n },\n });\n });\n }\n\n\n Utilities.setPropertyUnchecked(Element.prototype, 'setAttribute',\n /**\n * @this {Element}\n * @param {string} name\n * @param {string} newValue\n */\n function(name, newValue) {\n // Fast path for non-custom elements.\n if (this.__CE_state !== CEState.custom) {\n return EnvProxy.setAttribute(this, name, newValue);\n }\n\n const oldValue = EnvProxy.getAttribute(this, name);\n EnvProxy.setAttribute(this, name, newValue);\n newValue = EnvProxy.getAttribute(this, name);\n internals.attributeChangedCallback(this, name, oldValue, newValue, null);\n });\n\n Utilities.setPropertyUnchecked(Element.prototype, 'setAttributeNS',\n /**\n * @this {Element}\n * @param {?string} namespace\n * @param {string} name\n * @param {string} newValue\n */\n function(namespace, name, newValue) {\n // Fast path for non-custom elements.\n if (this.__CE_state !== CEState.custom) {\n return EnvProxy.setAttributeNS(this, namespace, name, newValue);\n }\n\n const oldValue = EnvProxy.getAttributeNS(this, namespace, name);\n EnvProxy.setAttributeNS(this, namespace, name, newValue);\n newValue = EnvProxy.getAttributeNS(this, namespace, name);\n internals.attributeChangedCallback(this, name, oldValue, newValue, namespace);\n });\n\n Utilities.setPropertyUnchecked(Element.prototype, 'removeAttribute',\n /**\n * @this {Element}\n * @param {string} name\n */\n function(name) {\n // Fast path for non-custom elements.\n if (this.__CE_state !== CEState.custom) {\n return EnvProxy.removeAttribute(this, name);\n }\n\n const oldValue = EnvProxy.getAttribute(this, name);\n EnvProxy.removeAttribute(this, name);\n if (oldValue !== null) {\n internals.attributeChangedCallback(this, name, oldValue, null, null);\n }\n });\n\n Utilities.setPropertyUnchecked(Element.prototype, 'removeAttributeNS',\n /**\n * @this {Element}\n * @param {?string} namespace\n * @param {string} name\n */\n function(namespace, name) {\n // Fast path for non-custom elements.\n if (this.__CE_state !== CEState.custom) {\n return EnvProxy.removeAttributeNS(this, namespace, name);\n }\n\n const oldValue = EnvProxy.getAttributeNS(this, namespace, name);\n EnvProxy.removeAttributeNS(this, namespace, name);\n // In older browsers, `Element#getAttributeNS` may return the empty string\n // instead of null if the attribute does not exist. For details, see;\n // https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttributeNS#Notes\n const newValue = EnvProxy.getAttributeNS(this, namespace, name);\n if (oldValue !== newValue) {\n internals.attributeChangedCallback(this, name, oldValue, newValue, namespace);\n }\n });\n\n\n function patch_insertAdjacentElement(destination, baseMethod) {\n Utilities.setPropertyUnchecked(destination, 'insertAdjacentElement',\n /**\n * @this {Element}\n * @param {string} where\n * @param {!Element} element\n * @return {?Element}\n */\n function(where, element) {\n const wasConnected = Utilities.isConnected(element);\n const insertedElement = /** @type {!Element} */\n (baseMethod.call(this, where, element));\n\n if (wasConnected) {\n internals.disconnectTree(element);\n }\n\n if (Utilities.isConnected(insertedElement)) {\n internals.connectTree(element);\n }\n return insertedElement;\n });\n }\n\n if (Env.HTMLElement['insertAdjacentElement'] && Env.HTMLElement['insertAdjacentElement'].value) {\n patch_insertAdjacentElement(HTMLElement.prototype, Env.HTMLElement['insertAdjacentElement'].value);\n } else if (Env.Element['insertAdjacentElement'] && Env.Element['insertAdjacentElement'].value) {\n patch_insertAdjacentElement(Element.prototype, Env.Element['insertAdjacentElement'].value);\n } else {\n console.warn('Custom Elements: `Element#insertAdjacentElement` was not patched.');\n }\n\n\n PatchParentNode(internals, Element.prototype, {\n prepend: (Env.Element.prepend || {}).value,\n append: (Env.Element.append || {}).value,\n });\n\n PatchChildNode(internals, Element.prototype, {\n before: (Env.Element.before || {}).value,\n after: (Env.Element.after || {}).value,\n replaceWith: (Env.Element.replaceWith || {}).value,\n remove: (Env.Element.remove || {}).value,\n });\n};\n"]} \ No newline at end of file +{"version":3,"sources":["src/AlreadyConstructedMarker.js","src/Environment.js","src/EnvironmentProxy.js","src/CustomElementInternals.js","src/Utilities.js","src/CustomElementState.js","src/DocumentConstructionObserver.js","src/Deferred.js","src/CustomElementRegistry.js","src/Patch/HTMLElement.js","src/custom-elements.js","src/Patch/Interface/ParentNode.js","src/Patch/Document.js","src/Patch/Node.js","src/Patch/Interface/ChildNode.js","src/Patch/Element.js"],"names":["$jscompDefaultExport","AlreadyConstructedMarker","getDescriptor$$module$$src$Environment","o","p","Object","getOwnPropertyDescriptor","envDocument_proto","window","envDocument","prototype","append","getDescriptor","prepend","envElement_proto","envElement","after","attachShadow","before","innerHTML","insertAdjacentElement","remove","replaceWith","envHTMLElement_proto","envHTMLElement","HTMLElement","envMutationObserver","envMutationObserver_proto","envNode_proto","envNode","textContent","getter$$module$$src$EnvironmentProxy","descriptor","get","undefined","method$$module$$src$EnvironmentProxy","value","createElementMethod","method","createElement","createElementNSMethod","createElementNS","createTextNodeMethod","createTextNode","importNodeMethod","importNode","readyStateGetter","getter","readyState","attachShadowMethod","Element$$module$$src$Environment.attachShadow","getAttributeMethod","getAttribute","getAttributeNSMethod","getAttributeNS","localNameGetter","localName","removeAttributeMethod","removeAttribute","removeAttributeNSMethod","removeAttributeNS","setAttributeMethod","setAttribute","setAttributeNSMethod","setAttributeNS","contentGetter","content","envHTMLTemplateElement","envHTMLTemplateElement_proto","observeMethod","observe","disconnectMethod","disconnect","addedNodesGetter","addedNodes","envMutationRecord","envMutationRecord_proto","addEventListenerMethod","addEventListener","addEventListener$$module$$src$EnvironmentProxy","node","callback","call","type","options","appendChildMethod","appendChild","childNodesGetter","childNodes","cloneNodeMethod","cloneNode","firstChildGetter","firstChild","insertBeforeMethod","insertBefore","isConnectedGetter","isConnected","nextSiblingGetter","nextSibling","nodeTypeGetter","nodeType","parentNodeGetter","parentNode","removeChildMethod","removeChild","replaceChildMethod","replaceChild","reservedTagList","Set","isValidCustomElementName$$module$$src$Utilities","isValidCustomElementName","reserved","has","validForm","test","isConnected$$module$$src$Utilities","nativeValue","current","__CE_isImportDocument","Document","ShadowRoot","host","nextSiblingOrAncestorSibling$$module$$src$Utilities","nextSiblingOrAncestorSibling","root","start","walkDeepDescendantElements$$module$$src$Utilities","walkDeepDescendantElements","visitedImports","Node","ELEMENT_NODE","element","name","import","add","child","shadowRoot","__CE_shadowRoot","setPropertyUnchecked$$module$$src$Utilities","setPropertyUnchecked","destination","constructor","CustomElementInternals","_localNameToDefinition","Map","_constructorToDefinition","_patches","_hasPatches","setDefinition","definition","set","addPatch","listener","push","patchTree","patch","__CE_patched","i","length","connectTree","elements","custom","__CE_state","connectedCallback","upgradeElement","disconnectTree","disconnectedCallback","patchAndUpgradeTree","gatherElements","__CE_hasRegistry","__CE_documentLoadHandled","delete","localNameToDefinition","constructionStack","result","Error","pop","e","failed","__CE_definition","attributeChangedCallback","observedAttributes","oldValue","newValue","namespace","indexOf","DocumentConstructionObserver","internals","doc","_internals","_document","_observer","_handleMutations","bind","childList","subtree","mutations","j","Deferred","_resolve","_value","_promise","Promise","resolve","CustomElementRegistry","_elementDefinitionIsRunning","_whenDefinedDeferred","_flushCallback","this._flushCallback","fn","_flushPending","_unflushedLocalNames","_documentConstructionObserver","document","define","Function","TypeError","SyntaxError","adoptedCallback","getCallback","callbackValue","_flush","shift","deferred","whenDefined","reject","prior","polyfillWrapFlushCallback","outer","inner","flush","$jscompDefaultExport$$module$$src$Patch$HTMLElement","setPrototypeOf","lastIndex","$jscompDefaultExport$$module$$src$Patch$Interface$ParentNode","builtIn","connectedBefore","nodes","filter","apply","Element","$jscompDefaultExport$$module$$src$Patch$Document","deep","clone","NS_HTML","Document$$module$$src$Environment.prepend","Document$$module$$src$Environment.append","$jscompDefaultExport$$module$$src$Patch$Node","patch_textContent","baseDescriptor","defineProperty","enumerable","configurable","assignedValue","TEXT_NODE","removedNodes","childNodesLength","Array","refNode","DocumentFragment","insertedNodes","slice","nativeResult","nodeWasConnected","ownerDocument","nodeToInsert","nodeToRemove","nodeToInsertWasConnected","thisIsConnected","Node$$module$$src$Environment.textContent","Node$$module$$src$Environment.textContent.get","parts","join","$jscompDefaultExport$$module$$src$Patch$Interface$ChildNode","Element$$module$$src$Environment.before","Element$$module$$src$Environment.after","Element$$module$$src$Environment.replaceWith","Element$$module$$src$Environment.remove","wasConnected","$jscompDefaultExport$$module$$src$Patch$Element","patch_innerHTML","htmlString","removedElements","patch_insertAdjacentElement","baseMethod","where","insertedElement","init","console","warn","Element$$module$$src$Environment.innerHTML","Element$$module$$src$Environment.innerHTML.get","HTMLElement$$module$$src$Environment.innerHTML","HTMLElement$$module$$src$Environment.innerHTML.get","rawDiv","Element$$module$$src$Environment.insertAdjacentElement","Element$$module$$src$Environment.insertAdjacentElement.value","Element$$module$$src$Environment.prepend","Element$$module$$src$Environment.append","priorCustomElements","customElements"],"mappings":"A;aASA,IAAAA,EAAe,IAFfC,QAAA,EAAA,E,CCPsBC,QAAA,EAAA,CAACC,CAAD,CAAIC,CAAJ,CAAU,CAAA,MAAAC,OAAAC,yBAAA,CAAgCH,CAAhC,CAAmCC,CAAnC,CAAA,CAGhC,IAAMG,EADcC,MAAAC,SACMC,UAA1B,CAMEC,GAAQC,CAAAD,CAAcJ,CAAdI,CAAiCA,QAAjCA,CANV,CAWEE,GAASD,CAAAC,CAAcN,CAAdM,CAAiCA,SAAjCA,CAXX,CAgBMC,EADaN,MAAAO,QACML,UAhBzB,CAqBEM,GAAOJ,CAAAI,CAAcF,CAAdE,CAAgCA,OAAhCA,CArBT,CAsBEL,GAAQC,CAAAD,CAAcG,CAAdH,CAAgCA,QAAhCA,CAtBV,CAuBEM,EAAcL,CAAAK,CAAcH,CAAdG,CAAgCA,cAAhCA,CAvBhB,CAwBEC,GAAQN,CAAAM,CAAcJ,CAAdI,CAAgCA,QAAhCA,CAxBV,CA2BEC,EAAWP,CAAAO,CAAcL,CAAdK,CAAgCA,WAAhCA,CA3Bb,CA4BEC,EAAuBR,CAAAQ,CAAcN,CAAdM,CAAgCA,uBAAhCA,CA5BzB,CA8BEP,GAASD,CAAAC,CAAcC,CAAdD,CAAgCA,SAAhCA,CA9BX,CA+BEQ,GAAQT,CAAAS,CAAcP,CAAdO,CAAgCA,QAAhCA,CA/BV,CAkCEC,GAAaV,CAA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A1B,CAEvBtL,OAAAqP,eAAA,CAAsBlP,MAAtB,CAA8B,gBAA9B,CAAgD,CAC9CoP,aAAc,CAAA,CADgC,CAE9CD,WAAY,CAAA,CAFkC,CAG9CvN,MAAOwQ,cAHuC,CAAhD,CAfsD","file":"custom-elements.min.js","sourcesContent":["/**\n * This class exists only to work around Closure's lack of a way to describe\n * singletons. It represents the 'already constructed marker' used in custom\n * element construction stacks.\n *\n * https://html.spec.whatwg.org/#concept-already-constructed-marker\n */\nclass AlreadyConstructedMarker {}\n\nexport default new AlreadyConstructedMarker();\n","const getDescriptor = (o, p) => Object.getOwnPropertyDescriptor(o, p);\n\nconst envDocument = window['Document'];\nconst envDocument_proto = envDocument.prototype;\nexport const Document = {\n self: envDocument,\n // Closure's renaming breaks if this property is named `prototype`.\n proto: envDocument_proto,\n\n append: getDescriptor(envDocument_proto, 'append'),\n createElement: getDescriptor(envDocument_proto, 'createElement'),\n createElementNS: getDescriptor(envDocument_proto, 'createElementNS'),\n createTextNode: getDescriptor(envDocument_proto, 'createTextNode'),\n importNode: getDescriptor(envDocument_proto, 'importNode'),\n prepend: getDescriptor(envDocument_proto, 'prepend'),\n readyState: getDescriptor(envDocument_proto, 'readyState'),\n};\n\nconst envElement = window['Element'];\nconst envElement_proto = envElement.prototype;\nexport const Element = {\n self: envElement,\n proto: envElement_proto,\n\n after: getDescriptor(envElement_proto, 'after'),\n append: getDescriptor(envElement_proto, 'append'),\n attachShadow: getDescriptor(envElement_proto, 'attachShadow'),\n before: getDescriptor(envElement_proto, 'before'),\n getAttribute: getDescriptor(envElement_proto, 'getAttribute'),\n getAttributeNS: getDescriptor(envElement_proto, 'getAttributeNS'),\n innerHTML: getDescriptor(envElement_proto, 'innerHTML'),\n insertAdjacentElement: getDescriptor(envElement_proto, 'insertAdjacentElement'),\n localName: getDescriptor(envElement_proto, 'localName'),\n prepend: getDescriptor(envElement_proto, 'prepend'),\n remove: getDescriptor(envElement_proto, 'remove'),\n removeAttribute: getDescriptor(envElement_proto, 'removeAttribute'),\n removeAttributeNS: getDescriptor(envElement_proto, 'removeAttributeNS'),\n replaceWith: getDescriptor(envElement_proto, 'replaceWith'),\n setAttribute: getDescriptor(envElement_proto, 'setAttribute'),\n setAttributeNS: getDescriptor(envElement_proto, 'setAttributeNS'),\n};\n\nconst envHTMLElement = window['HTMLElement'];\nconst envHTMLElement_proto = envHTMLElement['prototype'];\nexport const HTMLElement = {\n self: envHTMLElement,\n proto: envHTMLElement_proto,\n\n innerHTML: getDescriptor(envHTMLElement_proto, 'innerHTML'),\n};\n\nconst envHTMLTemplateElement = window['HTMLTemplateElement'];\nconst envHTMLTemplateElement_proto = envHTMLTemplateElement['prototype'];\nexport const HTMLTemplateElement = {\n self: envHTMLTemplateElement,\n proto: envHTMLTemplateElement_proto,\n\n content: getDescriptor(envHTMLTemplateElement_proto, 'content'),\n};\n\nconst envMutationObserver = window['MutationObserver'];\nconst envMutationObserver_proto = envMutationObserver['prototype'];\nexport const MutationObserver = {\n self: envMutationObserver,\n proto: envMutationObserver_proto,\n\n disconnect: getDescriptor(envMutationObserver_proto, 'disconnect'),\n observe: getDescriptor(envMutationObserver_proto, 'observe'),\n};\n\nconst envMutationRecord = window['MutationRecord'];\nconst envMutationRecord_proto = envMutationRecord['prototype'];\nexport const MutationRecord = {\n self: envMutationRecord,\n proto: envMutationRecord_proto,\n\n addedNodes: getDescriptor(envMutationRecord_proto, 'addedNodes'),\n};\n\nconst envNode = window['Node'];\nconst envNode_proto = envNode['prototype'];\nexport const Node = {\n self: envNode,\n proto: envNode_proto,\n\n addEventListener: getDescriptor(envNode_proto, 'addEventListener'),\n appendChild: getDescriptor(envNode_proto, 'appendChild'),\n childNodes: getDescriptor(envNode_proto, 'childNodes'),\n cloneNode: getDescriptor(envNode_proto, 'cloneNode'),\n firstChild: getDescriptor(envNode_proto, 'firstChild'),\n insertBefore: getDescriptor(envNode_proto, 'insertBefore'),\n isConnected: getDescriptor(envNode_proto, 'isConnected'),\n nextSibling: getDescriptor(envNode_proto, 'nextSibling'),\n nodeType: getDescriptor(envNode_proto, 'nodeType'),\n parentNode: getDescriptor(envNode_proto, 'parentNode'),\n removeChild: getDescriptor(envNode_proto, 'removeChild'),\n replaceChild: getDescriptor(envNode_proto, 'replaceChild'),\n textContent: getDescriptor(envNode_proto, 'textContent'),\n};\n","import * as Env from './Environment.js';\n\nconst getter = descriptor => descriptor ? descriptor.get : () => undefined;\nconst method = descriptor => descriptor ? descriptor.value : () => undefined;\n\n// Document\n\nconst createElementMethod = method(Env.Document.createElement);\nexport const createElement = (doc, localName) => createElementMethod.call(doc, localName);\n\nconst createElementNSMethod = method(Env.Document.createElementNS);\nexport const createElementNS = (doc, namespace, qualifiedName) => createElementNSMethod.call(doc, namespace, qualifiedName);\n\nconst createTextNodeMethod = method(Env.Document.createTextNode);\nexport const createTextNode = (doc, localName) => createTextNodeMethod.call(doc, localName);\n\nconst importNodeMethod = method(Env.Document.importNode);\nexport const importNode = (doc, node, deep) => importNodeMethod.call(doc, node, deep);\n\nconst readyStateGetter = getter(Env.Document.readyState);\nexport const readyState = doc => readyStateGetter.call(doc);\n\n// Element\n\nconst attachShadowMethod = method(Env.Element.attachShadow);\nexport const attachShadow = (node, options) => attachShadowMethod.call(node, options);\n\nconst getAttributeMethod = method(Env.Element.getAttribute);\nexport const getAttribute = (node, name) => getAttributeMethod.call(node, name);\n\nconst getAttributeNSMethod = method(Env.Element.getAttributeNS);\nexport const getAttributeNS = (node, ns, name) => getAttributeNSMethod.call(node, ns, name);\n\nconst localNameGetter = getter(Env.Element.localName);\nexport const localName = node => localNameGetter.call(node);\n\nconst removeAttributeMethod = method(Env.Element.removeAttribute);\nexport const removeAttribute = (node, name) => removeAttributeMethod.call(node, name);\n\nconst removeAttributeNSMethod = method(Env.Element.removeAttributeNS);\nexport const removeAttributeNS = (node, ns, name) => removeAttributeNSMethod.call(node, ns, name);\n\nconst setAttributeMethod = method(Env.Element.setAttribute);\nexport const setAttribute = (node, name, value) => setAttributeMethod.call(node, name, value);\n\nconst setAttributeNSMethod = method(Env.Element.setAttributeNS);\nexport const setAttributeNS = (node, ns, name, value) => setAttributeNSMethod.call(node, ns, name, value);\n\n// HTMLTemplateElement\n\nconst contentGetter = getter(Env.HTMLTemplateElement.content);\nexport const content = node => contentGetter.call(node);\n\n// MutationObserver\n\nconst observeMethod = method(Env.MutationObserver.observe);\nexport const observe = (mutationObserver, target, options) => observeMethod.call(mutationObserver, target, options);\n\nconst disconnectMethod = method(Env.MutationObserver.disconnect);\nexport const disconnect = mutationObserver => disconnectMethod.call(mutationObserver);\n\n// MutationRecord\n\nconst addedNodesGetter = getter(Env.MutationRecord.addedNodes);\nexport const addedNodes = node => addedNodesGetter.call(node);\n\n// Node\n\nconst addEventListenerMethod = method(Env.Node.addEventListener);\nexport const addEventListener = (node, type, callback, options) => addEventListenerMethod.call(node, type, callback, options);\n\nconst appendChildMethod = method(Env.Node.appendChild);\nexport const appendChild = (node, deep) => appendChildMethod.call(node, deep);\n\nconst childNodesGetter = getter(Env.Node.childNodes);\nexport const childNodes = node => childNodesGetter.call(node);\n\nconst cloneNodeMethod = method(Env.Node.cloneNode);\nexport const cloneNode = (node, deep) => cloneNodeMethod.call(node, deep);\n\nconst firstChildGetter = getter(Env.Node.firstChild);\nexport const firstChild = node => firstChildGetter.call(node);\n\nconst insertBeforeMethod = method(Env.Node.insertBefore);\nexport const insertBefore = (node, newChild, refChild) => insertBeforeMethod.call(node, newChild, refChild);\n\nconst isConnectedGetter = getter(Env.Node.isConnected);\nexport const isConnected = node => isConnectedGetter.call(node);\n\nconst nextSiblingGetter = getter(Env.Node.nextSibling);\nexport const nextSibling = node => nextSiblingGetter.call(node);\n\nconst nodeTypeGetter = getter(Env.Node.nodeType);\nexport const nodeType = node => nodeTypeGetter.call(node);\n\nconst parentNodeGetter = getter(Env.Node.parentNode);\nexport const parentNode = node => parentNodeGetter.call(node);\n\nconst removeChildMethod = method(Env.Node.removeChild);\nexport const removeChild = (node, deep) => removeChildMethod.call(node, deep);\n\nconst replaceChildMethod = method(Env.Node.replaceChild);\nexport const replaceChild = (node, newChild, oldChild) => replaceChildMethod.call(node, newChild, oldChild);\n","import * as EnvProxy from './EnvironmentProxy.js';\nimport * as Utilities from './Utilities.js';\nimport CEState from './CustomElementState.js';\n\nexport default class CustomElementInternals {\n constructor() {\n /** @type {!Map} */\n this._localNameToDefinition = new Map();\n\n /** @type {!Map} */\n this._constructorToDefinition = new Map();\n\n /** @type {!Array} */\n this._patches = [];\n\n /** @type {boolean} */\n this._hasPatches = false;\n }\n\n /**\n * @param {string} localName\n * @param {!CustomElementDefinition} definition\n */\n setDefinition(localName, definition) {\n this._localNameToDefinition.set(localName, definition);\n this._constructorToDefinition.set(definition.constructor, definition);\n }\n\n /**\n * @param {string} localName\n * @return {!CustomElementDefinition|undefined}\n */\n localNameToDefinition(localName) {\n return this._localNameToDefinition.get(localName);\n }\n\n /**\n * @param {!Function} constructor\n * @return {!CustomElementDefinition|undefined}\n */\n constructorToDefinition(constructor) {\n return this._constructorToDefinition.get(constructor);\n }\n\n /**\n * @param {!function(!Node)} listener\n */\n addPatch(listener) {\n this._hasPatches = true;\n this._patches.push(listener);\n }\n\n /**\n * @param {!Node} node\n */\n patchTree(node) {\n if (!this._hasPatches) return;\n\n Utilities.walkDeepDescendantElements(node, element => this.patch(element));\n }\n\n /**\n * @param {!Node} node\n */\n patch(node) {\n if (!this._hasPatches) return;\n\n if (node.__CE_patched) return;\n node.__CE_patched = true;\n\n for (let i = 0; i < this._patches.length; i++) {\n this._patches[i](node);\n }\n }\n\n /**\n * @param {!Node} root\n */\n connectTree(root) {\n const elements = [];\n\n Utilities.walkDeepDescendantElements(root, element => elements.push(element));\n\n for (let i = 0; i < elements.length; i++) {\n const element = elements[i];\n if (element.__CE_state === CEState.custom) {\n this.connectedCallback(element);\n } else {\n this.upgradeElement(element);\n }\n }\n }\n\n /**\n * @param {!Node} root\n */\n disconnectTree(root) {\n const elements = [];\n\n Utilities.walkDeepDescendantElements(root, element => elements.push(element));\n\n for (let i = 0; i < elements.length; i++) {\n const element = elements[i];\n if (element.__CE_state === CEState.custom) {\n this.disconnectedCallback(element);\n }\n }\n }\n\n /**\n * Upgrades all uncustomized custom elements at and below a root node for\n * which there is a definition. When custom element reaction callbacks are\n * assumed to be called synchronously (which, by the current DOM / HTML spec\n * definitions, they are *not*), callbacks for both elements customized\n * synchronously by the parser and elements being upgraded occur in the same\n * relative order.\n *\n * NOTE: This function, when used to simulate the construction of a tree that\n * is already created but not customized (i.e. by the parser), does *not*\n * prevent the element from reading the 'final' (true) state of the tree. For\n * example, the element, during truly synchronous parsing / construction would\n * see that it contains no children as they have not yet been inserted.\n * However, this function does not modify the tree, the element will\n * (incorrectly) have children. Additionally, self-modification restrictions\n * for custom element constructors imposed by the DOM spec are *not* enforced.\n *\n *\n * The following nested list shows the steps extending down from the HTML\n * spec's parsing section that cause elements to be synchronously created and\n * upgraded:\n *\n * The \"in body\" insertion mode:\n * https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody\n * - Switch on token:\n * .. other cases ..\n * -> Any other start tag\n * - [Insert an HTML element](below) for the token.\n *\n * Insert an HTML element:\n * https://html.spec.whatwg.org/multipage/syntax.html#insert-an-html-element\n * - Insert a foreign element for the token in the HTML namespace:\n * https://html.spec.whatwg.org/multipage/syntax.html#insert-a-foreign-element\n * - Create an element for a token:\n * https://html.spec.whatwg.org/multipage/syntax.html#create-an-element-for-the-token\n * - Will execute script flag is true?\n * - (Element queue pushed to the custom element reactions stack.)\n * - Create an element:\n * https://dom.spec.whatwg.org/#concept-create-element\n * - Sync CE flag is true?\n * - Constructor called.\n * - Self-modification restrictions enforced.\n * - Sync CE flag is false?\n * - (Upgrade reaction enqueued.)\n * - Attributes appended to element.\n * (`attributeChangedCallback` reactions enqueued.)\n * - Will execute script flag is true?\n * - (Element queue popped from the custom element reactions stack.\n * Reactions in the popped stack are invoked.)\n * - (Element queue pushed to the custom element reactions stack.)\n * - Insert the element:\n * https://dom.spec.whatwg.org/#concept-node-insert\n * - Shadow-including descendants are connected. During parsing\n * construction, there are no shadow-*excluding* descendants.\n * However, the constructor may have validly attached a shadow\n * tree to itself and added descendants to that shadow tree.\n * (`connectedCallback` reactions enqueued.)\n * - (Element queue popped from the custom element reactions stack.\n * Reactions in the popped stack are invoked.)\n *\n * @param {!Node} root\n * @param {!Set=} visitedImports\n */\n patchAndUpgradeTree(root, visitedImports = new Set()) {\n const elements = [];\n\n const gatherElements = element => {\n if (EnvProxy.localName(element) === 'link' && EnvProxy.getAttribute(element, 'rel') === 'import') {\n // The HTML Imports polyfill sets a descendant element of the link to\n // the `import` property, specifically this is *not* a Document.\n const importNode = /** @type {?Node} */ (element.import);\n\n if (importNode instanceof Node && importNode.readyState === 'complete') {\n importNode.__CE_isImportDocument = true;\n\n // Connected links are associated with the registry.\n importNode.__CE_hasRegistry = true;\n } else {\n // If this link's import root is not available, its contents can't be\n // walked. Wait for 'load' and walk it when it's ready.\n EnvProxy.addEventListener(element, 'load', () => {\n const importNode = /** @type {!Node} */ (element.import);\n\n if (importNode.__CE_documentLoadHandled) return;\n importNode.__CE_documentLoadHandled = true;\n\n importNode.__CE_isImportDocument = true;\n\n // Connected links are associated with the registry.\n importNode.__CE_hasRegistry = true;\n\n // Clone the `visitedImports` set that was populated sync during\n // the `patchAndUpgradeTree` call that caused this 'load' handler to\n // be added. Then, remove *this* link's import node so that we can\n // walk that import again, even if it was partially walked later\n // during the same `patchAndUpgradeTree` call.\n const clonedVisitedImports = new Set(visitedImports);\n visitedImports.delete(importNode);\n\n this.patchAndUpgradeTree(importNode, visitedImports);\n });\n }\n } else {\n elements.push(element);\n }\n };\n\n // `walkDeepDescendantElements` populates (and internally checks against)\n // `visitedImports` when traversing a loaded import.\n Utilities.walkDeepDescendantElements(root, gatherElements, visitedImports);\n\n if (this._hasPatches) {\n for (let i = 0; i < elements.length; i++) {\n this.patch(elements[i]);\n }\n }\n\n for (let i = 0; i < elements.length; i++) {\n this.upgradeElement(elements[i]);\n }\n }\n\n /**\n * @param {!Element} element\n */\n upgradeElement(element) {\n const currentState = element.__CE_state;\n if (currentState !== undefined) return;\n\n const definition = this.localNameToDefinition(element.localName);\n if (!definition) return;\n\n definition.constructionStack.push(element);\n\n const constructor = definition.constructor;\n try {\n try {\n let result = new (constructor)();\n if (result !== element) {\n throw new Error('The custom element constructor did not produce the element being upgraded.');\n }\n } finally {\n definition.constructionStack.pop();\n }\n } catch (e) {\n element.__CE_state = CEState.failed;\n throw e;\n }\n\n element.__CE_state = CEState.custom;\n element.__CE_definition = definition;\n\n if (definition.attributeChangedCallback) {\n const observedAttributes = definition.observedAttributes;\n for (let i = 0; i < observedAttributes.length; i++) {\n const name = observedAttributes[i];\n const value = EnvProxy.getAttribute(element, name);\n if (value !== null) {\n this.attributeChangedCallback(element, name, null, value, null);\n }\n }\n }\n\n if (Utilities.isConnected(element)) {\n this.connectedCallback(element);\n }\n }\n\n /**\n * @param {!Element} element\n */\n connectedCallback(element) {\n const definition = element.__CE_definition;\n if (definition.connectedCallback) {\n definition.connectedCallback.call(element);\n }\n }\n\n /**\n * @param {!Element} element\n */\n disconnectedCallback(element) {\n const definition = element.__CE_definition;\n if (definition.disconnectedCallback) {\n definition.disconnectedCallback.call(element);\n }\n }\n\n /**\n * @param {!Element} element\n * @param {string} name\n * @param {?string} oldValue\n * @param {?string} newValue\n * @param {?string} namespace\n */\n attributeChangedCallback(element, name, oldValue, newValue, namespace) {\n const definition = element.__CE_definition;\n if (\n definition.attributeChangedCallback &&\n definition.observedAttributes.indexOf(name) > -1\n ) {\n definition.attributeChangedCallback.call(element, name, oldValue, newValue, namespace);\n }\n }\n}\n","import * as EnvProxy from './EnvironmentProxy.js';\n\nconst reservedTagList = new Set([\n 'annotation-xml',\n 'color-profile',\n 'font-face',\n 'font-face-src',\n 'font-face-uri',\n 'font-face-format',\n 'font-face-name',\n 'missing-glyph',\n]);\n\n/**\n * @param {string} localName\n * @returns {boolean}\n */\nexport function isValidCustomElementName(localName) {\n const reserved = reservedTagList.has(localName);\n const validForm = /^[a-z][.0-9_a-z]*-[\\-.0-9_a-z]*$/.test(localName);\n return !reserved && validForm;\n}\n\n/**\n * @private\n * @param {!Node} node\n * @return {boolean}\n */\nexport function isConnected(node) {\n // Use `Node#isConnected`, if defined.\n const nativeValue = EnvProxy.isConnected(node);\n if (nativeValue !== undefined) {\n return nativeValue;\n }\n\n /** @type {?Node|undefined} */\n let current = node;\n while (current && !(current.__CE_isImportDocument || current instanceof Document)) {\n current = EnvProxy.parentNode(current) || (window.ShadowRoot && current instanceof ShadowRoot ? current.host : undefined);\n }\n return !!(current && (current.__CE_isImportDocument || current instanceof Document));\n}\n\n/**\n * @param {!Node} root\n * @param {!Node} start\n * @return {?Node}\n */\nfunction nextSiblingOrAncestorSibling(root, start) {\n let node = start;\n while (node && node !== root && !EnvProxy.nextSibling(node)) {\n node = EnvProxy.parentNode(node);\n }\n return (!node || node === root) ? null : EnvProxy.nextSibling(node);\n}\n\n/**\n * @param {!Node} root\n * @param {!Node} start\n * @return {?Node}\n */\nfunction nextNode(root, start) {\n return EnvProxy.firstChild(start) || nextSiblingOrAncestorSibling(root, start);\n}\n\n/**\n * @param {!Node} root\n * @param {!function(!Element)} callback\n * @param {!Set=} visitedImports\n */\nexport function walkDeepDescendantElements(root, callback, visitedImports = new Set()) {\n let node = root;\n while (node) {\n if (EnvProxy.nodeType(node) === Node.ELEMENT_NODE) {\n const element = /** @type {!Element} */(node);\n\n callback(element);\n\n const localName = EnvProxy.localName(element);\n if (localName === 'link' && EnvProxy.getAttribute(element, 'rel') === 'import') {\n // If this import (polyfilled or not) has it's root node available,\n // walk it.\n const importNode = /** @type {!Node} */ (element.import);\n if (importNode instanceof Node && !visitedImports.has(importNode)) {\n // Prevent multiple walks of the same import root.\n visitedImports.add(importNode);\n\n for (let child = EnvProxy.firstChild(importNode); child; child = EnvProxy.nextSibling(child)) {\n walkDeepDescendantElements(child, callback, visitedImports);\n }\n }\n\n // Ignore descendants of import links to prevent attempting to walk the\n // elements created by the HTML Imports polyfill that we just walked\n // above.\n node = nextSiblingOrAncestorSibling(root, element);\n continue;\n } else if (localName === 'template') {\n // Ignore descendants of templates. There shouldn't be any descendants\n // because they will be moved into `.content` during construction in\n // browsers that support template but, in case they exist and are still\n // waiting to be moved by a polyfill, they will be ignored.\n node = nextSiblingOrAncestorSibling(root, element);\n continue;\n }\n\n // Walk shadow roots.\n const shadowRoot = element.__CE_shadowRoot;\n if (shadowRoot) {\n for (let child = EnvProxy.firstChild(shadowRoot); child; child = EnvProxy.nextSibling(child)) {\n walkDeepDescendantElements(child, callback, visitedImports);\n }\n }\n }\n\n node = nextNode(root, node);\n }\n}\n\n/**\n * Used to suppress Closure's \"Modifying the prototype is only allowed if the\n * constructor is in the same scope\" warning without using\n * `@suppress {newCheckTypes, duplicate}` because `newCheckTypes` is too broad.\n *\n * @param {!Object} destination\n * @param {string} name\n * @param {*} value\n */\nexport function setPropertyUnchecked(destination, name, value) {\n destination[name] = value;\n}\n","/**\n * @enum {number}\n */\nconst CustomElementState = {\n custom: 1,\n failed: 2,\n};\n\nexport default CustomElementState;\n","import * as Env from './Environment.js';\nimport * as EnvProxy from './EnvironmentProxy.js';\nimport CustomElementInternals from './CustomElementInternals.js';\n\nexport default class DocumentConstructionObserver {\n constructor(internals, doc) {\n /**\n * @type {!CustomElementInternals}\n */\n this._internals = internals;\n\n /**\n * @type {!Document}\n */\n this._document = doc;\n\n /**\n * @type {MutationObserver|undefined}\n */\n this._observer = undefined;\n\n\n // Simulate tree construction for all currently accessible nodes in the\n // document.\n this._internals.patchAndUpgradeTree(this._document);\n\n if (EnvProxy.readyState(this._document) === 'loading') {\n this._observer = new Env.MutationObserver.self(this._handleMutations.bind(this));\n\n // Nodes created by the parser are given to the observer *before* the next\n // task runs. Inline scripts are run in a new task. This means that the\n // observer will be able to handle the newly parsed nodes before the inline\n // script is run.\n EnvProxy.observe(this._observer, this._document, {\n childList: true,\n subtree: true,\n });\n }\n }\n\n disconnect() {\n if (this._observer) {\n EnvProxy.disconnect(this._observer);\n }\n }\n\n /**\n * @param {!Array} mutations\n */\n _handleMutations(mutations) {\n // Once the document's `readyState` is 'interactive' or 'complete', all new\n // nodes created within that document will be the result of script and\n // should be handled by patching.\n const readyState = EnvProxy.readyState(this._document);\n if (readyState === 'interactive' || readyState === 'complete') {\n this.disconnect();\n }\n\n for (let i = 0; i < mutations.length; i++) {\n const addedNodes = EnvProxy.addedNodes(mutations[i]);\n for (let j = 0; j < addedNodes.length; j++) {\n const node = addedNodes[j];\n this._internals.patchAndUpgradeTree(node);\n }\n }\n }\n}\n","/**\n * @template T\n */\nexport default class Deferred {\n constructor() {\n /**\n * @private\n * @type {T|undefined}\n */\n this._value = undefined;\n\n /**\n * @private\n * @type {Function|undefined}\n */\n this._resolve = undefined;\n\n /**\n * @private\n * @type {!Promise}\n */\n this._promise = new Promise(resolve => {\n this._resolve = resolve;\n\n if (this._value) {\n resolve(this._value);\n }\n });\n }\n\n /**\n * @param {T} value\n */\n resolve(value) {\n if (this._value) {\n throw new Error('Already resolved.');\n }\n\n this._value = value;\n\n if (this._resolve) {\n this._resolve(value);\n }\n }\n\n /**\n * @return {!Promise}\n */\n toPromise() {\n return this._promise;\n }\n}\n","import CustomElementInternals from './CustomElementInternals.js';\nimport DocumentConstructionObserver from './DocumentConstructionObserver.js';\nimport Deferred from './Deferred.js';\nimport * as Utilities from './Utilities.js';\n\n/**\n * @unrestricted\n */\nexport default class CustomElementRegistry {\n\n /**\n * @param {!CustomElementInternals} internals\n */\n constructor(internals) {\n /**\n * @private\n * @type {boolean}\n */\n this._elementDefinitionIsRunning = false;\n\n /**\n * @private\n * @type {!CustomElementInternals}\n */\n this._internals = internals;\n\n /**\n * @private\n * @type {!Map>}\n */\n this._whenDefinedDeferred = new Map();\n\n /**\n * The default flush callback triggers the document walk synchronously.\n * @private\n * @type {!Function}\n */\n this._flushCallback = fn => fn();\n\n /**\n * @private\n * @type {boolean}\n */\n this._flushPending = false;\n\n /**\n * @private\n * @type {!Array}\n */\n this._unflushedLocalNames = [];\n\n /**\n * @private\n * @type {!DocumentConstructionObserver}\n */\n this._documentConstructionObserver = new DocumentConstructionObserver(internals, document);\n }\n\n /**\n * @param {string} localName\n * @param {!Function} constructor\n */\n define(localName, constructor) {\n if (!(constructor instanceof Function)) {\n throw new TypeError('Custom element constructors must be functions.');\n }\n\n if (!Utilities.isValidCustomElementName(localName)) {\n throw new SyntaxError(`The element name '${localName}' is not valid.`);\n }\n\n if (this._internals.localNameToDefinition(localName)) {\n throw new Error(`A custom element with name '${localName}' has already been defined.`);\n }\n\n if (this._elementDefinitionIsRunning) {\n throw new Error('A custom element is already being defined.');\n }\n this._elementDefinitionIsRunning = true;\n\n let connectedCallback;\n let disconnectedCallback;\n let adoptedCallback;\n let attributeChangedCallback;\n let observedAttributes;\n try {\n /** @type {!Object} */\n const prototype = constructor.prototype;\n if (!(prototype instanceof Object)) {\n throw new TypeError('The custom element constructor\\'s prototype is not an object.');\n }\n\n function getCallback(name) {\n const callbackValue = prototype[name];\n if (callbackValue !== undefined && !(callbackValue instanceof Function)) {\n throw new Error(`The '${name}' callback must be a function.`);\n }\n return callbackValue;\n }\n\n connectedCallback = getCallback('connectedCallback');\n disconnectedCallback = getCallback('disconnectedCallback');\n adoptedCallback = getCallback('adoptedCallback');\n attributeChangedCallback = getCallback('attributeChangedCallback');\n observedAttributes = constructor['observedAttributes'] || [];\n } catch (e) {\n return;\n } finally {\n this._elementDefinitionIsRunning = false;\n }\n\n const definition = {\n localName,\n constructor,\n connectedCallback,\n disconnectedCallback,\n adoptedCallback,\n attributeChangedCallback,\n observedAttributes,\n constructionStack: [],\n };\n\n this._internals.setDefinition(localName, definition);\n\n this._unflushedLocalNames.push(localName);\n\n // If we've already called the flush callback and it hasn't called back yet,\n // don't call it again.\n if (!this._flushPending) {\n this._flushPending = true;\n this._flushCallback(() => this._flush());\n }\n }\n\n _flush() {\n // If no new definitions were defined, don't attempt to flush. This could\n // happen if a flush callback keeps the function it is given and calls it\n // multiple times.\n if (this._flushPending === false) return;\n\n this._flushPending = false;\n this._internals.patchAndUpgradeTree(document);\n\n while (this._unflushedLocalNames.length > 0) {\n const localName = this._unflushedLocalNames.shift();\n const deferred = this._whenDefinedDeferred.get(localName);\n if (deferred) {\n deferred.resolve(undefined);\n }\n }\n }\n\n /**\n * @param {string} localName\n * @return {Function|undefined}\n */\n get(localName) {\n const definition = this._internals.localNameToDefinition(localName);\n if (definition) {\n return definition.constructor;\n }\n\n return undefined;\n }\n\n /**\n * @param {string} localName\n * @return {!Promise}\n */\n whenDefined(localName) {\n if (!Utilities.isValidCustomElementName(localName)) {\n return Promise.reject(new SyntaxError(`'${localName}' is not a valid custom element name.`));\n }\n\n const prior = this._whenDefinedDeferred.get(localName);\n if (prior) {\n return prior.toPromise();\n }\n\n const deferred = new Deferred();\n this._whenDefinedDeferred.set(localName, deferred);\n\n const definition = this._internals.localNameToDefinition(localName);\n // Resolve immediately only if the given local name has a definition *and*\n // the full document walk to upgrade elements with that local name has\n // already happened.\n if (definition && this._unflushedLocalNames.indexOf(localName) === -1) {\n deferred.resolve(undefined);\n }\n\n return deferred.toPromise();\n }\n\n polyfillWrapFlushCallback(outer) {\n this._documentConstructionObserver.disconnect();\n const inner = this._flushCallback;\n this._flushCallback = flush => outer(() => inner(flush));\n }\n}\n\n// Closure compiler exports.\nwindow['CustomElementRegistry'] = CustomElementRegistry;\nCustomElementRegistry.prototype['define'] = CustomElementRegistry.prototype.define;\nCustomElementRegistry.prototype['get'] = CustomElementRegistry.prototype.get;\nCustomElementRegistry.prototype['whenDefined'] = CustomElementRegistry.prototype.whenDefined;\nCustomElementRegistry.prototype['polyfillWrapFlushCallback'] = CustomElementRegistry.prototype.polyfillWrapFlushCallback;\n","import * as Env from '../Environment.js';\nimport * as EnvProxy from '../EnvironmentProxy.js';\nimport CustomElementInternals from '../CustomElementInternals.js';\nimport CEState from '../CustomElementState.js';\nimport AlreadyConstructedMarker from '../AlreadyConstructedMarker.js';\n\n/**\n * @param {!CustomElementInternals} internals\n */\nexport default function(internals) {\n window['HTMLElement'] = (function() {\n /**\n * @type {function(new: HTMLElement): !HTMLElement}\n */\n function HTMLElement() {\n // This should really be `new.target` but `new.target` can't be emulated\n // in ES5. Assuming the user keeps the default value of the constructor's\n // prototype's `constructor` property, this is equivalent.\n /** @type {!Function} */\n const constructor = this.constructor;\n\n const definition = internals.constructorToDefinition(constructor);\n if (!definition) {\n throw new Error('The custom element being constructed was not registered with `customElements`.');\n }\n\n const constructionStack = definition.constructionStack;\n\n if (constructionStack.length === 0) {\n const element = EnvProxy.createElement(document, definition.localName);\n Object.setPrototypeOf(element, constructor.prototype);\n element.__CE_state = CEState.custom;\n element.__CE_definition = definition;\n internals.patch(element);\n return element;\n }\n\n const lastIndex = constructionStack.length - 1;\n const element = constructionStack[lastIndex];\n if (element === AlreadyConstructedMarker) {\n throw new Error('The HTMLElement constructor was either called reentrantly for this constructor or called multiple times.');\n }\n constructionStack[lastIndex] = AlreadyConstructedMarker;\n\n Object.setPrototypeOf(element, constructor.prototype);\n internals.patch(/** @type {!HTMLElement} */ (element));\n\n return element;\n }\n\n HTMLElement.prototype = Env.HTMLElement.proto;\n\n return HTMLElement;\n })();\n};\n","/**\n * @license\n * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n */\n\nimport CustomElementInternals from './CustomElementInternals.js';\nimport CustomElementRegistry from './CustomElementRegistry.js';\n\nimport PatchHTMLElement from './Patch/HTMLElement.js';\nimport PatchDocument from './Patch/Document.js';\nimport PatchNode from './Patch/Node.js';\nimport PatchElement from './Patch/Element.js';\n\nconst priorCustomElements = window['customElements'];\n\nif (!priorCustomElements ||\n priorCustomElements['forcePolyfill'] ||\n (typeof priorCustomElements['define'] != 'function') ||\n (typeof priorCustomElements['get'] != 'function')) {\n /** @type {!CustomElementInternals} */\n const internals = new CustomElementInternals();\n\n PatchHTMLElement(internals);\n PatchDocument(internals);\n PatchNode(internals);\n PatchElement(internals);\n\n // The main document is always associated with the registry.\n document.__CE_hasRegistry = true;\n\n /** @type {!CustomElementRegistry} */\n const customElements = new CustomElementRegistry(internals);\n\n Object.defineProperty(window, 'customElements', {\n configurable: true,\n enumerable: true,\n value: customElements,\n });\n}\n","import CustomElementInternals from '../../CustomElementInternals.js';\nimport * as Utilities from '../../Utilities.js';\n\n/**\n * @typedef {{\n * prepend: !function(...(!Node|string)),\n * append: !function(...(!Node|string)),\n * }}\n */\nlet ParentNodeNativeMethods;\n\n/**\n * @param {!CustomElementInternals} internals\n * @param {!Object} destination\n * @param {!ParentNodeNativeMethods} builtIn\n */\nexport default function(internals, destination, builtIn) {\n /**\n * @param {...(!Node|string)} nodes\n */\n destination['prepend'] = function(...nodes) {\n // TODO: Fix this for when one of `nodes` is a DocumentFragment!\n const connectedBefore = /** @type {!Array} */ (nodes.filter(node => {\n // DocumentFragments are not connected and will not be added to the list.\n return node instanceof Node && Utilities.isConnected(node);\n }));\n\n builtIn.prepend.apply(this, nodes);\n\n for (let i = 0; i < connectedBefore.length; i++) {\n internals.disconnectTree(connectedBefore[i]);\n }\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node instanceof Element) {\n internals.connectTree(node);\n }\n }\n }\n };\n\n /**\n * @param {...(!Node|string)} nodes\n */\n destination['append'] = function(...nodes) {\n // TODO: Fix this for when one of `nodes` is a DocumentFragment!\n const connectedBefore = /** @type {!Array} */ (nodes.filter(node => {\n // DocumentFragments are not connected and will not be added to the list.\n return node instanceof Node && Utilities.isConnected(node);\n }));\n\n builtIn.append.apply(this, nodes);\n\n for (let i = 0; i < connectedBefore.length; i++) {\n internals.disconnectTree(connectedBefore[i]);\n }\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node instanceof Element) {\n internals.connectTree(node);\n }\n }\n }\n };\n};\n","import * as Env from '../Environment.js';\nimport * as EnvProxy from '../EnvironmentProxy.js';\nimport CustomElementInternals from '../CustomElementInternals.js';\nimport * as Utilities from '../Utilities.js';\n\nimport PatchParentNode from './Interface/ParentNode.js';\n\n/**\n * @param {!CustomElementInternals} internals\n */\nexport default function(internals) {\n Utilities.setPropertyUnchecked(Document.prototype, 'createElement',\n /**\n * @this {Document}\n * @param {string} localName\n * @return {!Element}\n */\n function(localName) {\n // Only create custom elements if this document is associated with the registry.\n if (this.__CE_hasRegistry) {\n const definition = internals.localNameToDefinition(localName);\n if (definition) {\n return new (definition.constructor)();\n }\n }\n\n const result = /** @type {!Element} */\n (EnvProxy.createElement(this, localName));\n internals.patch(result);\n return result;\n });\n\n Utilities.setPropertyUnchecked(Document.prototype, 'importNode',\n /**\n * @this {Document}\n * @param {!Node} node\n * @param {boolean=} deep\n * @return {!Node}\n */\n function(node, deep) {\n const clone = EnvProxy.importNode(this, node, deep);\n // Only create custom elements if this document is associated with the registry.\n if (!this.__CE_hasRegistry) {\n internals.patchTree(clone);\n } else {\n internals.patchAndUpgradeTree(clone);\n }\n return clone;\n });\n\n const NS_HTML = \"http://www.w3.org/1999/xhtml\";\n\n Utilities.setPropertyUnchecked(Document.prototype, 'createElementNS',\n /**\n * @this {Document}\n * @param {?string} namespace\n * @param {string} localName\n * @return {!Element}\n */\n function(namespace, localName) {\n // Only create custom elements if this document is associated with the registry.\n if (this.__CE_hasRegistry && (namespace === null || namespace === NS_HTML)) {\n const definition = internals.localNameToDefinition(localName);\n if (definition) {\n return new (definition.constructor)();\n }\n }\n\n const result = /** @type {!Element} */\n (EnvProxy.createElementNS(this, namespace, localName));\n internals.patch(result);\n return result;\n });\n\n PatchParentNode(internals, Document.prototype, {\n prepend: (Env.Document.prepend || {}).value,\n append: (Env.Document.append || {}).value,\n });\n};\n","import * as Env from '../Environment.js';\nimport * as EnvProxy from '../EnvironmentProxy.js';\nimport CustomElementInternals from '../CustomElementInternals.js';\nimport * as Utilities from '../Utilities.js';\n\n/**\n * @param {!CustomElementInternals} internals\n */\nexport default function(internals) {\n // `Node#nodeValue` is implemented on `Attr`.\n // `Node#textContent` is implemented on `Attr`, `Element`.\n\n Utilities.setPropertyUnchecked(Node.prototype, 'insertBefore',\n /**\n * @this {Node}\n * @param {!Node} node\n * @param {?Node} refNode\n * @return {!Node}\n */\n function(node, refNode) {\n if (node instanceof DocumentFragment) {\n const insertedNodes = Array.prototype.slice.apply(EnvProxy.childNodes(node));\n const nativeResult = EnvProxy.insertBefore(this, node, refNode);\n\n // DocumentFragments can't be connected, so `disconnectTree` will never\n // need to be called on a DocumentFragment's children after inserting it.\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < insertedNodes.length; i++) {\n internals.connectTree(insertedNodes[i]);\n }\n }\n\n return nativeResult;\n }\n\n const nodeWasConnected = Utilities.isConnected(node);\n const nativeResult = EnvProxy.insertBefore(this, node, refNode);\n\n if (nodeWasConnected) {\n internals.disconnectTree(node);\n }\n\n if (Utilities.isConnected(this)) {\n internals.connectTree(node);\n }\n\n return nativeResult;\n });\n\n Utilities.setPropertyUnchecked(Node.prototype, 'appendChild',\n /**\n * @this {Node}\n * @param {!Node} node\n * @return {!Node}\n */\n function(node) {\n if (node instanceof DocumentFragment) {\n const insertedNodes = Array.prototype.slice.apply(EnvProxy.childNodes(node));\n const nativeResult = EnvProxy.appendChild(this, node);\n\n // DocumentFragments can't be connected, so `disconnectTree` will never\n // need to be called on a DocumentFragment's children after inserting it.\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < insertedNodes.length; i++) {\n internals.connectTree(insertedNodes[i]);\n }\n }\n\n return nativeResult;\n }\n\n const nodeWasConnected = Utilities.isConnected(node);\n const nativeResult = EnvProxy.appendChild(this, node);\n\n if (nodeWasConnected) {\n internals.disconnectTree(node);\n }\n\n if (Utilities.isConnected(this)) {\n internals.connectTree(node);\n }\n\n return nativeResult;\n });\n\n Utilities.setPropertyUnchecked(Node.prototype, 'cloneNode',\n /**\n * @this {Node}\n * @param {boolean=} deep\n * @return {!Node}\n */\n function(deep) {\n const clone = EnvProxy.cloneNode(this, deep);\n // Only create custom elements if this element's owner document is\n // associated with the registry.\n if (!this.ownerDocument.__CE_hasRegistry) {\n internals.patchTree(clone);\n } else {\n internals.patchAndUpgradeTree(clone);\n }\n return clone;\n });\n\n Utilities.setPropertyUnchecked(Node.prototype, 'removeChild',\n /**\n * @this {Node}\n * @param {!Node} node\n * @return {!Node}\n */\n function(node) {\n const nodeWasConnected = Utilities.isConnected(node);\n const nativeResult = EnvProxy.removeChild(this, node);\n\n if (nodeWasConnected) {\n internals.disconnectTree(node);\n }\n\n return nativeResult;\n });\n\n Utilities.setPropertyUnchecked(Node.prototype, 'replaceChild',\n /**\n * @this {Node}\n * @param {!Node} nodeToInsert\n * @param {!Node} nodeToRemove\n * @return {!Node}\n */\n function(nodeToInsert, nodeToRemove) {\n if (nodeToInsert instanceof DocumentFragment) {\n const insertedNodes = Array.prototype.slice.apply(EnvProxy.childNodes(nodeToInsert));\n const nativeResult = EnvProxy.replaceChild(this, nodeToInsert, nodeToRemove);\n\n // DocumentFragments can't be connected, so `disconnectTree` will never\n // need to be called on a DocumentFragment's children after inserting it.\n\n if (Utilities.isConnected(this)) {\n internals.disconnectTree(nodeToRemove);\n for (let i = 0; i < insertedNodes.length; i++) {\n internals.connectTree(insertedNodes[i]);\n }\n }\n\n return nativeResult;\n }\n\n const nodeToInsertWasConnected = Utilities.isConnected(nodeToInsert);\n const nativeResult = EnvProxy.replaceChild(this, nodeToInsert, nodeToRemove);\n const thisIsConnected = Utilities.isConnected(this);\n\n if (thisIsConnected) {\n internals.disconnectTree(nodeToRemove);\n }\n\n if (nodeToInsertWasConnected) {\n internals.disconnectTree(nodeToInsert);\n }\n\n if (thisIsConnected) {\n internals.connectTree(nodeToInsert);\n }\n\n return nativeResult;\n });\n\n\n function patch_textContent(destination, baseDescriptor) {\n Object.defineProperty(destination, 'textContent', {\n enumerable: baseDescriptor.enumerable,\n configurable: true,\n get: baseDescriptor.get,\n set: /** @this {Node} */ function(assignedValue) {\n // If this is a text node then there are no nodes to disconnect.\n if (this.nodeType === Node.TEXT_NODE) {\n baseDescriptor.set.call(this, assignedValue);\n return;\n }\n\n let removedNodes = undefined;\n // Checking for `firstChild` is faster than reading `childNodes.length`\n // to compare with 0.\n if (EnvProxy.firstChild(this)) {\n // Using `childNodes` is faster than `children`, even though we only\n // care about elements.\n const childNodes = EnvProxy.childNodes(this);\n const childNodesLength = childNodes.length;\n if (childNodesLength > 0 && Utilities.isConnected(this)) {\n // Copying an array by iterating is faster than using slice.\n removedNodes = new Array(childNodesLength);\n for (let i = 0; i < childNodesLength; i++) {\n removedNodes[i] = childNodes[i];\n }\n }\n }\n\n baseDescriptor.set.call(this, assignedValue);\n\n if (removedNodes) {\n for (let i = 0; i < removedNodes.length; i++) {\n internals.disconnectTree(removedNodes[i]);\n }\n }\n },\n });\n }\n\n if (Env.Node.textContent && Env.Node.textContent.get) {\n patch_textContent(Node.prototype, Env.Node.textContent);\n } else {\n internals.addPatch(function(element) {\n patch_textContent(element, {\n enumerable: true,\n configurable: true,\n // NOTE: This implementation of the `textContent` getter assumes that\n // text nodes' `textContent` getter will not be patched.\n get: /** @this {Node} */ function() {\n /** @type {!Array} */\n const parts = [];\n\n const childNodes = EnvProxy.childNodes(this);\n for (let i = 0; i < childNodes.length; i++) {\n parts.push(childNodes[i].textContent);\n }\n\n return parts.join('');\n },\n set: /** @this {Node} */ function(assignedValue) {\n let child;\n while (child = EnvProxy.firstChild(this)) {\n EnvProxy.removeChild(this, child);\n }\n EnvProxy.appendChild(this, EnvProxy.createTextNode(document, assignedValue));\n },\n });\n });\n }\n};\n","import CustomElementInternals from '../../CustomElementInternals.js';\nimport * as Utilities from '../../Utilities.js';\n\n/**\n * @typedef {{\n * before: !function(...(!Node|string)),\n * after: !function(...(!Node|string)),\n * replaceWith: !function(...(!Node|string)),\n * remove: !function(),\n * }}\n */\nlet ChildNodeNativeMethods;\n\n/**\n * @param {!CustomElementInternals} internals\n * @param {!Object} destination\n * @param {!ChildNodeNativeMethods} builtIn\n */\nexport default function(internals, destination, builtIn) {\n /**\n * @param {...(!Node|string)} nodes\n */\n destination['before'] = function(...nodes) {\n // TODO: Fix this for when one of `nodes` is a DocumentFragment!\n const connectedBefore = /** @type {!Array} */ (nodes.filter(node => {\n // DocumentFragments are not connected and will not be added to the list.\n return node instanceof Node && Utilities.isConnected(node);\n }));\n\n builtIn.before.apply(this, nodes);\n\n for (let i = 0; i < connectedBefore.length; i++) {\n internals.disconnectTree(connectedBefore[i]);\n }\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node instanceof Element) {\n internals.connectTree(node);\n }\n }\n }\n };\n\n /**\n * @param {...(!Node|string)} nodes\n */\n destination['after'] = function(...nodes) {\n // TODO: Fix this for when one of `nodes` is a DocumentFragment!\n const connectedBefore = /** @type {!Array} */ (nodes.filter(node => {\n // DocumentFragments are not connected and will not be added to the list.\n return node instanceof Node && Utilities.isConnected(node);\n }));\n\n builtIn.after.apply(this, nodes);\n\n for (let i = 0; i < connectedBefore.length; i++) {\n internals.disconnectTree(connectedBefore[i]);\n }\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node instanceof Element) {\n internals.connectTree(node);\n }\n }\n }\n };\n\n /**\n * @param {...(!Node|string)} nodes\n */\n destination['replaceWith'] = function(...nodes) {\n // TODO: Fix this for when one of `nodes` is a DocumentFragment!\n const connectedBefore = /** @type {!Array} */ (nodes.filter(node => {\n // DocumentFragments are not connected and will not be added to the list.\n return node instanceof Node && Utilities.isConnected(node);\n }));\n\n const wasConnected = Utilities.isConnected(this);\n\n builtIn.replaceWith.apply(this, nodes);\n\n for (let i = 0; i < connectedBefore.length; i++) {\n internals.disconnectTree(connectedBefore[i]);\n }\n\n if (wasConnected) {\n internals.disconnectTree(this);\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node instanceof Element) {\n internals.connectTree(node);\n }\n }\n }\n };\n\n destination['remove'] = function() {\n const wasConnected = Utilities.isConnected(this);\n\n builtIn.remove.call(this);\n\n if (wasConnected) {\n internals.disconnectTree(this);\n }\n };\n};\n","import * as Env from '../Environment.js';\nimport * as EnvProxy from '../EnvironmentProxy.js';\nimport CustomElementInternals from '../CustomElementInternals.js';\nimport CEState from '../CustomElementState.js';\nimport * as Utilities from '../Utilities.js';\n\nimport PatchParentNode from './Interface/ParentNode.js';\nimport PatchChildNode from './Interface/ChildNode.js';\n\n/**\n * @param {!CustomElementInternals} internals\n */\nexport default function(internals) {\n if (Env.Element.attachShadow) {\n Utilities.setPropertyUnchecked(Element.prototype, 'attachShadow',\n /**\n * @this {Element}\n * @param {!{mode: string}} init\n * @return {ShadowRoot}\n */\n function(init) {\n const shadowRoot = EnvProxy.attachShadow(this, init);\n this.__CE_shadowRoot = shadowRoot;\n return shadowRoot;\n });\n } else {\n console.warn('Custom Elements: `Element#attachShadow` was not patched.');\n }\n\n\n function patch_innerHTML(destination, baseDescriptor) {\n Object.defineProperty(destination, 'innerHTML', {\n enumerable: baseDescriptor.enumerable,\n configurable: true,\n get: baseDescriptor.get,\n set: /** @this {Element} */ function(htmlString) {\n const isConnected = Utilities.isConnected(this);\n\n // NOTE: In IE11, when using the native `innerHTML` setter, all nodes\n // that were previously descendants of the context element have all of\n // their children removed as part of the set - the entire subtree is\n // 'disassembled'. This work around walks the subtree *before* using the\n // native setter.\n /** @type {!Array|undefined} */\n let removedElements = undefined;\n if (isConnected) {\n removedElements = [];\n Utilities.walkDeepDescendantElements(this, element => {\n if (element !== this) {\n removedElements.push(element);\n }\n });\n }\n\n baseDescriptor.set.call(this, htmlString);\n\n if (removedElements) {\n for (let i = 0; i < removedElements.length; i++) {\n const element = removedElements[i];\n if (element.__CE_state === CEState.custom) {\n internals.disconnectedCallback(element);\n }\n }\n }\n\n // Only create custom elements if this element's owner document is\n // associated with the registry.\n if (!this.ownerDocument.__CE_hasRegistry) {\n internals.patchTree(this);\n } else {\n internals.patchAndUpgradeTree(this);\n }\n return htmlString;\n },\n });\n }\n\n if (Env.Element.innerHTML && Env.Element.innerHTML.get) {\n patch_innerHTML(Element.prototype, Env.Element.innerHTML);\n } else if (Env.HTMLElement.innerHTML && Env.HTMLElement.innerHTML.get) {\n patch_innerHTML(HTMLElement.prototype, Env.HTMLElement.innerHTML);\n } else {\n // In this case, `innerHTML` has no exposed getter but still exists. Rather\n // than using the environment proxy, we have to get and set it directly.\n\n /** @type {HTMLDivElement} */\n const rawDiv = EnvProxy.createElement(document, 'div');\n\n internals.addPatch(function(element) {\n patch_innerHTML(element, {\n enumerable: true,\n configurable: true,\n // Implements getting `innerHTML` by performing an unpatched `cloneNode`\n // of the element and returning the resulting element's `innerHTML`.\n // TODO: Is this too expensive?\n get: /** @this {Element} */ function() {\n return EnvProxy.cloneNode(this, true).innerHTML;\n },\n // Implements setting `innerHTML` by creating an unpatched element,\n // setting `innerHTML` of that element and replacing the target\n // element's children with those of the unpatched element.\n set: /** @this {Element} */ function(assignedValue) {\n // NOTE: re-route to `content` for `template` elements.\n // We need to do this because `template.appendChild` does not\n // route into `template.content`.\n /** @type {!Node} */\n const content =\n (EnvProxy.localName(this) === 'template')\n ? EnvProxy.content(/** @type {!HTMLTemplateElement} */ (this))\n : this;\n rawDiv.innerHTML = assignedValue;\n\n while (EnvProxy.childNodes(content).length > 0) {\n EnvProxy.removeChild(content, content.childNodes[0]);\n }\n while (EnvProxy.childNodes(rawDiv).length > 0) {\n EnvProxy.appendChild(content, rawDiv.childNodes[0]);\n }\n },\n });\n });\n }\n\n\n Utilities.setPropertyUnchecked(Element.prototype, 'setAttribute',\n /**\n * @this {Element}\n * @param {string} name\n * @param {string} newValue\n */\n function(name, newValue) {\n // Fast path for non-custom elements.\n if (this.__CE_state !== CEState.custom) {\n return EnvProxy.setAttribute(this, name, newValue);\n }\n\n const oldValue = EnvProxy.getAttribute(this, name);\n EnvProxy.setAttribute(this, name, newValue);\n newValue = EnvProxy.getAttribute(this, name);\n internals.attributeChangedCallback(this, name, oldValue, newValue, null);\n });\n\n Utilities.setPropertyUnchecked(Element.prototype, 'setAttributeNS',\n /**\n * @this {Element}\n * @param {?string} namespace\n * @param {string} name\n * @param {string} newValue\n */\n function(namespace, name, newValue) {\n // Fast path for non-custom elements.\n if (this.__CE_state !== CEState.custom) {\n return EnvProxy.setAttributeNS(this, namespace, name, newValue);\n }\n\n const oldValue = EnvProxy.getAttributeNS(this, namespace, name);\n EnvProxy.setAttributeNS(this, namespace, name, newValue);\n newValue = EnvProxy.getAttributeNS(this, namespace, name);\n internals.attributeChangedCallback(this, name, oldValue, newValue, namespace);\n });\n\n Utilities.setPropertyUnchecked(Element.prototype, 'removeAttribute',\n /**\n * @this {Element}\n * @param {string} name\n */\n function(name) {\n // Fast path for non-custom elements.\n if (this.__CE_state !== CEState.custom) {\n return EnvProxy.removeAttribute(this, name);\n }\n\n const oldValue = EnvProxy.getAttribute(this, name);\n EnvProxy.removeAttribute(this, name);\n if (oldValue !== null) {\n internals.attributeChangedCallback(this, name, oldValue, null, null);\n }\n });\n\n Utilities.setPropertyUnchecked(Element.prototype, 'removeAttributeNS',\n /**\n * @this {Element}\n * @param {?string} namespace\n * @param {string} name\n */\n function(namespace, name) {\n // Fast path for non-custom elements.\n if (this.__CE_state !== CEState.custom) {\n return EnvProxy.removeAttributeNS(this, namespace, name);\n }\n\n const oldValue = EnvProxy.getAttributeNS(this, namespace, name);\n EnvProxy.removeAttributeNS(this, namespace, name);\n // In older browsers, `Element#getAttributeNS` may return the empty string\n // instead of null if the attribute does not exist. For details, see;\n // https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttributeNS#Notes\n const newValue = EnvProxy.getAttributeNS(this, namespace, name);\n if (oldValue !== newValue) {\n internals.attributeChangedCallback(this, name, oldValue, newValue, namespace);\n }\n });\n\n\n function patch_insertAdjacentElement(destination, baseMethod) {\n Utilities.setPropertyUnchecked(destination, 'insertAdjacentElement',\n /**\n * @this {Element}\n * @param {string} where\n * @param {!Element} element\n * @return {?Element}\n */\n function(where, element) {\n const wasConnected = Utilities.isConnected(element);\n const insertedElement = /** @type {!Element} */\n (baseMethod.call(this, where, element));\n\n if (wasConnected) {\n internals.disconnectTree(element);\n }\n\n if (Utilities.isConnected(insertedElement)) {\n internals.connectTree(element);\n }\n return insertedElement;\n });\n }\n\n if (Env.HTMLElement.insertAdjacentElement && Env.HTMLElement.insertAdjacentElement.value) {\n patch_insertAdjacentElement(HTMLElement.prototype, Env.HTMLElement.insertAdjacentElement.value);\n } else if (Env.Element.insertAdjacentElement && Env.Element.insertAdjacentElement.value) {\n patch_insertAdjacentElement(Element.prototype, Env.Element.insertAdjacentElement.value);\n } else {\n console.warn('Custom Elements: `Element#insertAdjacentElement` was not patched.');\n }\n\n\n PatchParentNode(internals, Element.prototype, {\n prepend: (Env.Element.prepend || {}).value,\n append: (Env.Element.append || {}).value,\n });\n\n PatchChildNode(internals, Element.prototype, {\n before: (Env.Element.before || {}).value,\n after: (Env.Element.after || {}).value,\n replaceWith: (Env.Element.replaceWith || {}).value,\n remove: (Env.Element.remove || {}).value,\n });\n};\n"]} \ No newline at end of file From 6746ae63e8c55388d76691cece9f062f11d6708e Mon Sep 17 00:00:00 2001 From: Russell Bicknell Date: Wed, 14 Jun 2017 15:00:42 -0700 Subject: [PATCH 11/92] Environment: Always look up prototype with a string for Closure. --- src/Environment.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Environment.js b/src/Environment.js index 628458b..97033f2 100644 --- a/src/Environment.js +++ b/src/Environment.js @@ -1,7 +1,7 @@ const getDescriptor = (o, p) => Object.getOwnPropertyDescriptor(o, p); const envDocument = window['Document']; -const envDocument_proto = envDocument.prototype; +const envDocument_proto = envDocument['prototype']; export const Document = { self: envDocument, // Closure's renaming breaks if this property is named `prototype`. @@ -17,7 +17,7 @@ export const Document = { }; const envElement = window['Element']; -const envElement_proto = envElement.prototype; +const envElement_proto = envElement['prototype']; export const Element = { self: envElement, proto: envElement_proto, From 7d2af06da7f7e254a0a31a31b782ad3228e7ebc5 Mon Sep 17 00:00:00 2001 From: Russell Bicknell Date: Wed, 14 Jun 2017 15:01:36 -0700 Subject: [PATCH 12/92] build --- custom-elements.min.js.map | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom-elements.min.js.map b/custom-elements.min.js.map index 90b01b5..f19d7fa 100644 --- a/custom-elements.min.js.map +++ b/custom-elements.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["src/AlreadyConstructedMarker.js","src/Environment.js","src/EnvironmentProxy.js","src/CustomElementInternals.js","src/Utilities.js","src/CustomElementState.js","src/DocumentConstructionObserver.js","src/Deferred.js","src/CustomElementRegistry.js","src/Patch/HTMLElement.js","src/custom-elements.js","src/Patch/Interface/ParentNode.js","src/Patch/Document.js","src/Patch/Node.js","src/Patch/Interface/ChildNode.js","src/Patch/Element.js"],"names":["$jscompDefaultExport","AlreadyConstructedMarker","getDescriptor$$module$$src$Environment","o","p","Object","getOwnPropertyDescriptor","envDocument_proto","window","envDocument","prototype","append","getDescriptor","prepend","envElement_proto","envElement","after","attachShadow","before","innerHTML","insertAdjacentElement","remove","replaceWith","envHTMLElement_proto","envHTMLElement","HTMLElement","envMutationObserver","envMutationObserver_proto","envNode_proto","envNode","textContent","getter$$module$$src$EnvironmentProxy","descriptor","get","undefined","method$$module$$src$EnvironmentProxy","value","createElementMethod","method","createElement","createElementNSMethod","createElementNS","createTextNodeMethod","createTextNode","importNodeMethod","importNode","readyStateGetter","getter","readyState","attachShadowMethod","Element$$module$$src$Environment.attachShadow","getAttributeMethod","getAttribute","getAttributeNSMethod","getAttributeNS","localNameGetter","localName","removeAttributeMethod","removeAttribute","removeAttributeNSMethod","removeAttributeNS","setAttributeMethod","setAttribute","setAttributeNSMethod","setAttributeNS","contentGetter","content","envHTMLTemplateElement","envHTMLTemplateElement_proto","observeMethod","observe","disconnectMethod","disconnect","addedNodesGetter","addedNodes","envMutationRecord","envMutationRecord_proto","addEventListenerMethod","addEventListener","addEventListener$$module$$src$EnvironmentProxy","node","callback","call","type","options","appendChildMethod","appendChild","childNodesGetter","childNodes","cloneNodeMethod","cloneNode","firstChildGetter","firstChild","insertBeforeMethod","insertBefore","isConnectedGetter","isConnected","nextSiblingGetter","nextSibling","nodeTypeGetter","nodeType","parentNodeGetter","parentNode","removeChildMethod","removeChild","replaceChildMethod","replaceChild","reservedTagList","Set","isValidCustomElementName$$module$$src$Utilities","isValidCustomElementName","reserved","has","validForm","test","isConnected$$module$$src$Utilities","nativeValue","current","__CE_isImportDocument","Document","ShadowRoot","host","nextSiblingOrAncestorSibling$$module$$src$Utilities","nextSiblingOrAncestorSibling","root","start","walkDeepDescendantElements$$module$$src$Utilities","walkDeepDescendantElements","visitedImports","Node","ELEMENT_NODE","element","name","import","add","child","shadowRoot","__CE_shadowRoot","setPropertyUnchecked$$module$$src$Utilities","setPropertyUnchecked","destination","constructor","CustomElementInternals","_localNameToDefinition","Map","_constructorToDefinition","_patches","_hasPatches","setDefinition","definition","set","addPatch","listener","push","patchTree","patch","__CE_patched","i","length","connectTree","elements","custom","__CE_state","connectedCallback","upgradeElement","disconnectTree","disconnectedCallback","patchAndUpgradeTree","gatherElements","__CE_hasRegistry","__CE_documentLoadHandled","delete","localNameToDefinition","constructionStack","result","Error","pop","e","failed","__CE_definition","attributeChangedCallback","observedAttributes","oldValue","newValue","namespace","indexOf","DocumentConstructionObserver","internals","doc","_internals","_document","_observer","_handleMutations","bind","childList","subtree","mutations","j","Deferred","_resolve","_value","_promise","Promise","resolve","CustomElementRegistry","_elementDefinitionIsRunning","_whenDefinedDeferred","_flushCallback","this._flushCallback","fn","_flushPending","_unflushedLocalNames","_documentConstructionObserver","document","define","Function","TypeError","SyntaxError","adoptedCallback","getCallback","callbackValue","_flush","shift","deferred","whenDefined","reject","prior","polyfillWrapFlushCallback","outer","inner","flush","$jscompDefaultExport$$module$$src$Patch$HTMLElement","setPrototypeOf","lastIndex","$jscompDefaultExport$$module$$src$Patch$Interface$ParentNode","builtIn","connectedBefore","nodes","filter","apply","Element","$jscompDefaultExport$$module$$src$Patch$Document","deep","clone","NS_HTML","Document$$module$$src$Environment.prepend","Document$$module$$src$Environment.append","$jscompDefaultExport$$module$$src$Patch$Node","patch_textContent","baseDescriptor","defineProperty","enumerable","configurable","assignedValue","TEXT_NODE","removedNodes","childNodesLength","Array","refNode","DocumentFragment","insertedNodes","slice","nativeResult","nodeWasConnected","ownerDocument","nodeToInsert","nodeToRemove","nodeToInsertWasConnected","thisIsConnected","Node$$module$$src$Environment.textContent","Node$$module$$src$Environment.textContent.get","parts","join","$jscompDefaultExport$$module$$src$Patch$Interface$ChildNode","Element$$module$$src$Environment.before","Element$$module$$src$Environment.after","Element$$module$$src$Environment.replaceWith","Element$$module$$src$Environment.remove","wasConnected","$jscompDefaultExport$$module$$src$Patch$Element","patch_innerHTML","htmlString","removedElements","patch_insertAdjacentElement","baseMethod","where","insertedElement","init","console","warn","Element$$module$$src$Environment.innerHTML","Element$$module$$src$Environment.innerHTML.get","HTMLElement$$module$$src$Environment.innerHTML","HTMLElement$$module$$src$Environment.innerHTML.get","rawDiv","Element$$module$$src$Environment.insertAdjacentElement","Element$$module$$src$Environment.insertAdjacentElement.value","Element$$module$$src$Environment.prepend","Element$$module$$src$Environment.append","priorCustomElements","customElements"],"mappings":"A;aASA,IAAAA,EAAe,IAFfC,QAAA,EAAA,E,CCPsBC,QAAA,EAAA,CAACC,CAAD,CAAIC,CAAJ,CAAU,CAAA,MAAAC,OAAAC,yBAAA,CAAgCH,CAAhC,CAAmCC,CAAnC,CAAA,CAGhC,IAAMG,EADcC,MAAAC,SACMC,UAA1B,CAMEC,GAAQC,CAAAD,CAAcJ,CAAdI,CAAiCA,QA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ADK,CAGL4P,OAAAC,KAAA,CAAa,mEAAb,CJxNWjS;EI4Nb,CAAgB2L,CAAhB,CAA2BqD,OAAAtO,UAA3B,CAA8C,CAC5CG,EAASuB,CAACqQ,EAADrQ,EAAwB,EAAxBA,OADmC,CAE5CzB,OAAQyB,CAACsQ,EAADtQ,EAAuB,EAAvBA,OAFoC,CAA9C,CD1NapC,GC+Nb,CAAe2L,CAAf,CArOiC,C;;;;;;;;;ALMnC,IAAMgH,EAAsBnS,MAAA,eAE5B,IAAKmS,CAAAA,CAAL,EACKA,CAAA,cADL,EAE8C,UAF9C,EAEM,MAAOA,EAAA,OAFb,EAG2C,UAH3C,EAGM,MAAOA,EAAA,IAHb,CAGwD,CAEtD,IAAMhH,EAAY,IPrBL7C,CMKA9I,GCkBb,EEjBaA,GFkBb,EGpBaA,GHqBb,EKjBaA,GLkBb,EAGAqN,SAAA5C,iBAAA,CAA4B,CAAA,CAG5B,KAAMmI,eAAiB,IF5BVhG,CE4BU,CAA0BjB,CAA1B,CAEvBtL,OAAAqP,eAAA,CAAsBlP,MAAtB,CAA8B,gBAA9B,CAAgD,CAC9CoP,aAAc,CAAA,CADgC,CAE9CD,WAAY,CAAA,CAFkC,CAG9CvN,MAAOwQ,cAHuC,CAAhD,CAfsD","file":"custom-elements.min.js","sourcesContent":["/**\n * This class exists only to work around Closure's lack of a way to describe\n * singletons. It represents the 'already constructed marker' used in custom\n * element construction stacks.\n *\n * https://html.spec.whatwg.org/#concept-already-constructed-marker\n */\nclass AlreadyConstructedMarker {}\n\nexport default new AlreadyConstructedMarker();\n","const getDescriptor = (o, p) => Object.getOwnPropertyDescriptor(o, p);\n\nconst envDocument = window['Document'];\nconst envDocument_proto = envDocument.prototype;\nexport const Document = {\n self: envDocument,\n // Closure's renaming breaks if this property is named `prototype`.\n proto: envDocument_proto,\n\n append: getDescriptor(envDocument_proto, 'append'),\n createElement: getDescriptor(envDocument_proto, 'createElement'),\n createElementNS: getDescriptor(envDocument_proto, 'createElementNS'),\n createTextNode: getDescriptor(envDocument_proto, 'createTextNode'),\n importNode: getDescriptor(envDocument_proto, 'importNode'),\n prepend: getDescriptor(envDocument_proto, 'prepend'),\n readyState: getDescriptor(envDocument_proto, 'readyState'),\n};\n\nconst envElement = window['Element'];\nconst envElement_proto = envElement.prototype;\nexport const Element = {\n self: envElement,\n proto: envElement_proto,\n\n after: getDescriptor(envElement_proto, 'after'),\n append: getDescriptor(envElement_proto, 'append'),\n attachShadow: getDescriptor(envElement_proto, 'attachShadow'),\n before: getDescriptor(envElement_proto, 'before'),\n getAttribute: getDescriptor(envElement_proto, 'getAttribute'),\n getAttributeNS: getDescriptor(envElement_proto, 'getAttributeNS'),\n innerHTML: getDescriptor(envElement_proto, 'innerHTML'),\n insertAdjacentElement: getDescriptor(envElement_proto, 'insertAdjacentElement'),\n localName: getDescriptor(envElement_proto, 'localName'),\n prepend: getDescriptor(envElement_proto, 'prepend'),\n remove: getDescriptor(envElement_proto, 'remove'),\n removeAttribute: getDescriptor(envElement_proto, 'removeAttribute'),\n removeAttributeNS: getDescriptor(envElement_proto, 'removeAttributeNS'),\n replaceWith: getDescriptor(envElement_proto, 'replaceWith'),\n setAttribute: getDescriptor(envElement_proto, 'setAttribute'),\n setAttributeNS: getDescriptor(envElement_proto, 'setAttributeNS'),\n};\n\nconst envHTMLElement = window['HTMLElement'];\nconst envHTMLElement_proto = envHTMLElement['prototype'];\nexport const HTMLElement = {\n self: envHTMLElement,\n proto: envHTMLElement_proto,\n\n innerHTML: getDescriptor(envHTMLElement_proto, 'innerHTML'),\n};\n\nconst envHTMLTemplateElement = window['HTMLTemplateElement'];\nconst envHTMLTemplateElement_proto = envHTMLTemplateElement['prototype'];\nexport const HTMLTemplateElement = {\n self: envHTMLTemplateElement,\n proto: envHTMLTemplateElement_proto,\n\n content: getDescriptor(envHTMLTemplateElement_proto, 'content'),\n};\n\nconst envMutationObserver = window['MutationObserver'];\nconst envMutationObserver_proto = envMutationObserver['prototype'];\nexport const MutationObserver = {\n self: envMutationObserver,\n proto: envMutationObserver_proto,\n\n disconnect: getDescriptor(envMutationObserver_proto, 'disconnect'),\n observe: getDescriptor(envMutationObserver_proto, 'observe'),\n};\n\nconst envMutationRecord = window['MutationRecord'];\nconst envMutationRecord_proto = envMutationRecord['prototype'];\nexport const MutationRecord = {\n self: envMutationRecord,\n proto: envMutationRecord_proto,\n\n addedNodes: getDescriptor(envMutationRecord_proto, 'addedNodes'),\n};\n\nconst envNode = window['Node'];\nconst envNode_proto = envNode['prototype'];\nexport const Node = {\n self: envNode,\n proto: envNode_proto,\n\n addEventListener: getDescriptor(envNode_proto, 'addEventListener'),\n appendChild: getDescriptor(envNode_proto, 'appendChild'),\n childNodes: getDescriptor(envNode_proto, 'childNodes'),\n cloneNode: getDescriptor(envNode_proto, 'cloneNode'),\n firstChild: getDescriptor(envNode_proto, 'firstChild'),\n insertBefore: getDescriptor(envNode_proto, 'insertBefore'),\n isConnected: getDescriptor(envNode_proto, 'isConnected'),\n nextSibling: getDescriptor(envNode_proto, 'nextSibling'),\n nodeType: getDescriptor(envNode_proto, 'nodeType'),\n parentNode: getDescriptor(envNode_proto, 'parentNode'),\n removeChild: getDescriptor(envNode_proto, 'removeChild'),\n replaceChild: getDescriptor(envNode_proto, 'replaceChild'),\n textContent: getDescriptor(envNode_proto, 'textContent'),\n};\n","import * as Env from './Environment.js';\n\nconst getter = descriptor => descriptor ? descriptor.get : () => undefined;\nconst method = descriptor => descriptor ? descriptor.value : () => undefined;\n\n// Document\n\nconst createElementMethod = method(Env.Document.createElement);\nexport const createElement = (doc, localName) => createElementMethod.call(doc, localName);\n\nconst createElementNSMethod = method(Env.Document.createElementNS);\nexport const createElementNS = (doc, namespace, qualifiedName) => createElementNSMethod.call(doc, namespace, qualifiedName);\n\nconst createTextNodeMethod = method(Env.Document.createTextNode);\nexport const createTextNode = (doc, localName) => createTextNodeMethod.call(doc, localName);\n\nconst importNodeMethod = method(Env.Document.importNode);\nexport const importNode = (doc, node, deep) => importNodeMethod.call(doc, node, deep);\n\nconst readyStateGetter = getter(Env.Document.readyState);\nexport const readyState = doc => readyStateGetter.call(doc);\n\n// Element\n\nconst attachShadowMethod = method(Env.Element.attachShadow);\nexport const attachShadow = (node, options) => attachShadowMethod.call(node, options);\n\nconst getAttributeMethod = method(Env.Element.getAttribute);\nexport const getAttribute = (node, name) => getAttributeMethod.call(node, name);\n\nconst getAttributeNSMethod = method(Env.Element.getAttributeNS);\nexport const getAttributeNS = (node, ns, name) => getAttributeNSMethod.call(node, ns, name);\n\nconst localNameGetter = getter(Env.Element.localName);\nexport const localName = node => localNameGetter.call(node);\n\nconst removeAttributeMethod = method(Env.Element.removeAttribute);\nexport const removeAttribute = (node, name) => removeAttributeMethod.call(node, name);\n\nconst removeAttributeNSMethod = method(Env.Element.removeAttributeNS);\nexport const removeAttributeNS = (node, ns, name) => removeAttributeNSMethod.call(node, ns, name);\n\nconst setAttributeMethod = method(Env.Element.setAttribute);\nexport const setAttribute = (node, name, value) => setAttributeMethod.call(node, name, value);\n\nconst setAttributeNSMethod = method(Env.Element.setAttributeNS);\nexport const setAttributeNS = (node, ns, name, value) => setAttributeNSMethod.call(node, ns, name, value);\n\n// HTMLTemplateElement\n\nconst contentGetter = getter(Env.HTMLTemplateElement.content);\nexport const content = node => contentGetter.call(node);\n\n// MutationObserver\n\nconst observeMethod = method(Env.MutationObserver.observe);\nexport const observe = (mutationObserver, target, options) => observeMethod.call(mutationObserver, target, options);\n\nconst disconnectMethod = method(Env.MutationObserver.disconnect);\nexport const disconnect = mutationObserver => disconnectMethod.call(mutationObserver);\n\n// MutationRecord\n\nconst addedNodesGetter = getter(Env.MutationRecord.addedNodes);\nexport const addedNodes = node => addedNodesGetter.call(node);\n\n// Node\n\nconst addEventListenerMethod = method(Env.Node.addEventListener);\nexport const addEventListener = (node, type, callback, options) => addEventListenerMethod.call(node, type, callback, options);\n\nconst appendChildMethod = method(Env.Node.appendChild);\nexport const appendChild = (node, deep) => appendChildMethod.call(node, deep);\n\nconst childNodesGetter = getter(Env.Node.childNodes);\nexport const childNodes = node => childNodesGetter.call(node);\n\nconst cloneNodeMethod = method(Env.Node.cloneNode);\nexport const cloneNode = (node, deep) => cloneNodeMethod.call(node, deep);\n\nconst firstChildGetter = getter(Env.Node.firstChild);\nexport const firstChild = node => firstChildGetter.call(node);\n\nconst insertBeforeMethod = method(Env.Node.insertBefore);\nexport const insertBefore = (node, newChild, refChild) => insertBeforeMethod.call(node, newChild, refChild);\n\nconst isConnectedGetter = getter(Env.Node.isConnected);\nexport const isConnected = node => isConnectedGetter.call(node);\n\nconst nextSiblingGetter = getter(Env.Node.nextSibling);\nexport const nextSibling = node => nextSiblingGetter.call(node);\n\nconst nodeTypeGetter = getter(Env.Node.nodeType);\nexport const nodeType = node => nodeTypeGetter.call(node);\n\nconst parentNodeGetter = getter(Env.Node.parentNode);\nexport const parentNode = node => parentNodeGetter.call(node);\n\nconst removeChildMethod = method(Env.Node.removeChild);\nexport const removeChild = (node, deep) => removeChildMethod.call(node, deep);\n\nconst replaceChildMethod = method(Env.Node.replaceChild);\nexport const replaceChild = (node, newChild, oldChild) => replaceChildMethod.call(node, newChild, oldChild);\n","import * as EnvProxy from './EnvironmentProxy.js';\nimport * as Utilities from './Utilities.js';\nimport CEState from './CustomElementState.js';\n\nexport default class CustomElementInternals {\n constructor() {\n /** @type {!Map} */\n this._localNameToDefinition = new Map();\n\n /** @type {!Map} */\n this._constructorToDefinition = new Map();\n\n /** @type {!Array} */\n this._patches = [];\n\n /** @type {boolean} */\n this._hasPatches = false;\n }\n\n /**\n * @param {string} localName\n * @param {!CustomElementDefinition} definition\n */\n setDefinition(localName, definition) {\n this._localNameToDefinition.set(localName, definition);\n this._constructorToDefinition.set(definition.constructor, definition);\n }\n\n /**\n * @param {string} localName\n * @return {!CustomElementDefinition|undefined}\n */\n localNameToDefinition(localName) {\n return this._localNameToDefinition.get(localName);\n }\n\n /**\n * @param {!Function} constructor\n * @return {!CustomElementDefinition|undefined}\n */\n constructorToDefinition(constructor) {\n return this._constructorToDefinition.get(constructor);\n }\n\n /**\n * @param {!function(!Node)} listener\n */\n addPatch(listener) {\n this._hasPatches = true;\n this._patches.push(listener);\n }\n\n /**\n * @param {!Node} node\n */\n patchTree(node) {\n if (!this._hasPatches) return;\n\n Utilities.walkDeepDescendantElements(node, element => this.patch(element));\n }\n\n /**\n * @param {!Node} node\n */\n patch(node) {\n if (!this._hasPatches) return;\n\n if (node.__CE_patched) return;\n node.__CE_patched = true;\n\n for (let i = 0; i < this._patches.length; i++) {\n this._patches[i](node);\n }\n }\n\n /**\n * @param {!Node} root\n */\n connectTree(root) {\n const elements = [];\n\n Utilities.walkDeepDescendantElements(root, element => elements.push(element));\n\n for (let i = 0; i < elements.length; i++) {\n const element = elements[i];\n if (element.__CE_state === CEState.custom) {\n this.connectedCallback(element);\n } else {\n this.upgradeElement(element);\n }\n }\n }\n\n /**\n * @param {!Node} root\n */\n disconnectTree(root) {\n const elements = [];\n\n Utilities.walkDeepDescendantElements(root, element => elements.push(element));\n\n for (let i = 0; i < elements.length; i++) {\n const element = elements[i];\n if (element.__CE_state === CEState.custom) {\n this.disconnectedCallback(element);\n }\n }\n }\n\n /**\n * Upgrades all uncustomized custom elements at and below a root node for\n * which there is a definition. When custom element reaction callbacks are\n * assumed to be called synchronously (which, by the current DOM / HTML spec\n * definitions, they are *not*), callbacks for both elements customized\n * synchronously by the parser and elements being upgraded occur in the same\n * relative order.\n *\n * NOTE: This function, when used to simulate the construction of a tree that\n * is already created but not customized (i.e. by the parser), does *not*\n * prevent the element from reading the 'final' (true) state of the tree. For\n * example, the element, during truly synchronous parsing / construction would\n * see that it contains no children as they have not yet been inserted.\n * However, this function does not modify the tree, the element will\n * (incorrectly) have children. Additionally, self-modification restrictions\n * for custom element constructors imposed by the DOM spec are *not* enforced.\n *\n *\n * The following nested list shows the steps extending down from the HTML\n * spec's parsing section that cause elements to be synchronously created and\n * upgraded:\n *\n * The \"in body\" insertion mode:\n * https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody\n * - Switch on token:\n * .. other cases ..\n * -> Any other start tag\n * - [Insert an HTML element](below) for the token.\n *\n * Insert an HTML element:\n * https://html.spec.whatwg.org/multipage/syntax.html#insert-an-html-element\n * - Insert a foreign element for the token in the HTML namespace:\n * https://html.spec.whatwg.org/multipage/syntax.html#insert-a-foreign-element\n * - Create an element for a token:\n * https://html.spec.whatwg.org/multipage/syntax.html#create-an-element-for-the-token\n * - Will execute script flag is true?\n * - (Element queue pushed to the custom element reactions stack.)\n * - Create an element:\n * https://dom.spec.whatwg.org/#concept-create-element\n * - Sync CE flag is true?\n * - Constructor called.\n * - Self-modification restrictions enforced.\n * - Sync CE flag is false?\n * - (Upgrade reaction enqueued.)\n * - Attributes appended to element.\n * (`attributeChangedCallback` reactions enqueued.)\n * - Will execute script flag is true?\n * - (Element queue popped from the custom element reactions stack.\n * Reactions in the popped stack are invoked.)\n * - (Element queue pushed to the custom element reactions stack.)\n * - Insert the element:\n * https://dom.spec.whatwg.org/#concept-node-insert\n * - Shadow-including descendants are connected. During parsing\n * construction, there are no shadow-*excluding* descendants.\n * However, the constructor may have validly attached a shadow\n * tree to itself and added descendants to that shadow tree.\n * (`connectedCallback` reactions enqueued.)\n * - (Element queue popped from the custom element reactions stack.\n * Reactions in the popped stack are invoked.)\n *\n * @param {!Node} root\n * @param {!Set=} visitedImports\n */\n patchAndUpgradeTree(root, visitedImports = new Set()) {\n const elements = [];\n\n const gatherElements = element => {\n if (EnvProxy.localName(element) === 'link' && EnvProxy.getAttribute(element, 'rel') === 'import') {\n // The HTML Imports polyfill sets a descendant element of the link to\n // the `import` property, specifically this is *not* a Document.\n const importNode = /** @type {?Node} */ (element.import);\n\n if (importNode instanceof Node && importNode.readyState === 'complete') {\n importNode.__CE_isImportDocument = true;\n\n // Connected links are associated with the registry.\n importNode.__CE_hasRegistry = true;\n } else {\n // If this link's import root is not available, its contents can't be\n // walked. Wait for 'load' and walk it when it's ready.\n EnvProxy.addEventListener(element, 'load', () => {\n const importNode = /** @type {!Node} */ (element.import);\n\n if (importNode.__CE_documentLoadHandled) return;\n importNode.__CE_documentLoadHandled = true;\n\n importNode.__CE_isImportDocument = true;\n\n // Connected links are associated with the registry.\n importNode.__CE_hasRegistry = true;\n\n // Clone the `visitedImports` set that was populated sync during\n // the `patchAndUpgradeTree` call that caused this 'load' handler to\n // be added. Then, remove *this* link's import node so that we can\n // walk that import again, even if it was partially walked later\n // during the same `patchAndUpgradeTree` call.\n const clonedVisitedImports = new Set(visitedImports);\n visitedImports.delete(importNode);\n\n this.patchAndUpgradeTree(importNode, visitedImports);\n });\n }\n } else {\n elements.push(element);\n }\n };\n\n // `walkDeepDescendantElements` populates (and internally checks against)\n // `visitedImports` when traversing a loaded import.\n Utilities.walkDeepDescendantElements(root, gatherElements, visitedImports);\n\n if (this._hasPatches) {\n for (let i = 0; i < elements.length; i++) {\n this.patch(elements[i]);\n }\n }\n\n for (let i = 0; i < elements.length; i++) {\n this.upgradeElement(elements[i]);\n }\n }\n\n /**\n * @param {!Element} element\n */\n upgradeElement(element) {\n const currentState = element.__CE_state;\n if (currentState !== undefined) return;\n\n const definition = this.localNameToDefinition(element.localName);\n if (!definition) return;\n\n definition.constructionStack.push(element);\n\n const constructor = definition.constructor;\n try {\n try {\n let result = new (constructor)();\n if (result !== element) {\n throw new Error('The custom element constructor did not produce the element being upgraded.');\n }\n } finally {\n definition.constructionStack.pop();\n }\n } catch (e) {\n element.__CE_state = CEState.failed;\n throw e;\n }\n\n element.__CE_state = CEState.custom;\n element.__CE_definition = definition;\n\n if (definition.attributeChangedCallback) {\n const observedAttributes = definition.observedAttributes;\n for (let i = 0; i < observedAttributes.length; i++) {\n const name = observedAttributes[i];\n const value = EnvProxy.getAttribute(element, name);\n if (value !== null) {\n this.attributeChangedCallback(element, name, null, value, null);\n }\n }\n }\n\n if (Utilities.isConnected(element)) {\n this.connectedCallback(element);\n }\n }\n\n /**\n * @param {!Element} element\n */\n connectedCallback(element) {\n const definition = element.__CE_definition;\n if (definition.connectedCallback) {\n definition.connectedCallback.call(element);\n }\n }\n\n /**\n * @param {!Element} element\n */\n disconnectedCallback(element) {\n const definition = element.__CE_definition;\n if (definition.disconnectedCallback) {\n definition.disconnectedCallback.call(element);\n }\n }\n\n /**\n * @param {!Element} element\n * @param {string} name\n * @param {?string} oldValue\n * @param {?string} newValue\n * @param {?string} namespace\n */\n attributeChangedCallback(element, name, oldValue, newValue, namespace) {\n const definition = element.__CE_definition;\n if (\n definition.attributeChangedCallback &&\n definition.observedAttributes.indexOf(name) > -1\n ) {\n definition.attributeChangedCallback.call(element, name, oldValue, newValue, namespace);\n }\n }\n}\n","import * as EnvProxy from './EnvironmentProxy.js';\n\nconst reservedTagList = new Set([\n 'annotation-xml',\n 'color-profile',\n 'font-face',\n 'font-face-src',\n 'font-face-uri',\n 'font-face-format',\n 'font-face-name',\n 'missing-glyph',\n]);\n\n/**\n * @param {string} localName\n * @returns {boolean}\n */\nexport function isValidCustomElementName(localName) {\n const reserved = reservedTagList.has(localName);\n const validForm = /^[a-z][.0-9_a-z]*-[\\-.0-9_a-z]*$/.test(localName);\n return !reserved && validForm;\n}\n\n/**\n * @private\n * @param {!Node} node\n * @return {boolean}\n */\nexport function isConnected(node) {\n // Use `Node#isConnected`, if defined.\n const nativeValue = EnvProxy.isConnected(node);\n if (nativeValue !== undefined) {\n return nativeValue;\n }\n\n /** @type {?Node|undefined} */\n let current = node;\n while (current && !(current.__CE_isImportDocument || current instanceof Document)) {\n current = EnvProxy.parentNode(current) || (window.ShadowRoot && current instanceof ShadowRoot ? current.host : undefined);\n }\n return !!(current && (current.__CE_isImportDocument || current instanceof Document));\n}\n\n/**\n * @param {!Node} root\n * @param {!Node} start\n * @return {?Node}\n */\nfunction nextSiblingOrAncestorSibling(root, start) {\n let node = start;\n while (node && node !== root && !EnvProxy.nextSibling(node)) {\n node = EnvProxy.parentNode(node);\n }\n return (!node || node === root) ? null : EnvProxy.nextSibling(node);\n}\n\n/**\n * @param {!Node} root\n * @param {!Node} start\n * @return {?Node}\n */\nfunction nextNode(root, start) {\n return EnvProxy.firstChild(start) || nextSiblingOrAncestorSibling(root, start);\n}\n\n/**\n * @param {!Node} root\n * @param {!function(!Element)} callback\n * @param {!Set=} visitedImports\n */\nexport function walkDeepDescendantElements(root, callback, visitedImports = new Set()) {\n let node = root;\n while (node) {\n if (EnvProxy.nodeType(node) === Node.ELEMENT_NODE) {\n const element = /** @type {!Element} */(node);\n\n callback(element);\n\n const localName = EnvProxy.localName(element);\n if (localName === 'link' && EnvProxy.getAttribute(element, 'rel') === 'import') {\n // If this import (polyfilled or not) has it's root node available,\n // walk it.\n const importNode = /** @type {!Node} */ (element.import);\n if (importNode instanceof Node && !visitedImports.has(importNode)) {\n // Prevent multiple walks of the same import root.\n visitedImports.add(importNode);\n\n for (let child = EnvProxy.firstChild(importNode); child; child = EnvProxy.nextSibling(child)) {\n walkDeepDescendantElements(child, callback, visitedImports);\n }\n }\n\n // Ignore descendants of import links to prevent attempting to walk the\n // elements created by the HTML Imports polyfill that we just walked\n // above.\n node = nextSiblingOrAncestorSibling(root, element);\n continue;\n } else if (localName === 'template') {\n // Ignore descendants of templates. There shouldn't be any descendants\n // because they will be moved into `.content` during construction in\n // browsers that support template but, in case they exist and are still\n // waiting to be moved by a polyfill, they will be ignored.\n node = nextSiblingOrAncestorSibling(root, element);\n continue;\n }\n\n // Walk shadow roots.\n const shadowRoot = element.__CE_shadowRoot;\n if (shadowRoot) {\n for (let child = EnvProxy.firstChild(shadowRoot); child; child = EnvProxy.nextSibling(child)) {\n walkDeepDescendantElements(child, callback, visitedImports);\n }\n }\n }\n\n node = nextNode(root, node);\n }\n}\n\n/**\n * Used to suppress Closure's \"Modifying the prototype is only allowed if the\n * constructor is in the same scope\" warning without using\n * `@suppress {newCheckTypes, duplicate}` because `newCheckTypes` is too broad.\n *\n * @param {!Object} destination\n * @param {string} name\n * @param {*} value\n */\nexport function setPropertyUnchecked(destination, name, value) {\n destination[name] = value;\n}\n","/**\n * @enum {number}\n */\nconst CustomElementState = {\n custom: 1,\n failed: 2,\n};\n\nexport default CustomElementState;\n","import * as Env from './Environment.js';\nimport * as EnvProxy from './EnvironmentProxy.js';\nimport CustomElementInternals from './CustomElementInternals.js';\n\nexport default class DocumentConstructionObserver {\n constructor(internals, doc) {\n /**\n * @type {!CustomElementInternals}\n */\n this._internals = internals;\n\n /**\n * @type {!Document}\n */\n this._document = doc;\n\n /**\n * @type {MutationObserver|undefined}\n */\n this._observer = undefined;\n\n\n // Simulate tree construction for all currently accessible nodes in the\n // document.\n this._internals.patchAndUpgradeTree(this._document);\n\n if (EnvProxy.readyState(this._document) === 'loading') {\n this._observer = new Env.MutationObserver.self(this._handleMutations.bind(this));\n\n // Nodes created by the parser are given to the observer *before* the next\n // task runs. Inline scripts are run in a new task. This means that the\n // observer will be able to handle the newly parsed nodes before the inline\n // script is run.\n EnvProxy.observe(this._observer, this._document, {\n childList: true,\n subtree: true,\n });\n }\n }\n\n disconnect() {\n if (this._observer) {\n EnvProxy.disconnect(this._observer);\n }\n }\n\n /**\n * @param {!Array} mutations\n */\n _handleMutations(mutations) {\n // Once the document's `readyState` is 'interactive' or 'complete', all new\n // nodes created within that document will be the result of script and\n // should be handled by patching.\n const readyState = EnvProxy.readyState(this._document);\n if (readyState === 'interactive' || readyState === 'complete') {\n this.disconnect();\n }\n\n for (let i = 0; i < mutations.length; i++) {\n const addedNodes = EnvProxy.addedNodes(mutations[i]);\n for (let j = 0; j < addedNodes.length; j++) {\n const node = addedNodes[j];\n this._internals.patchAndUpgradeTree(node);\n }\n }\n }\n}\n","/**\n * @template T\n */\nexport default class Deferred {\n constructor() {\n /**\n * @private\n * @type {T|undefined}\n */\n this._value = undefined;\n\n /**\n * @private\n * @type {Function|undefined}\n */\n this._resolve = undefined;\n\n /**\n * @private\n * @type {!Promise}\n */\n this._promise = new Promise(resolve => {\n this._resolve = resolve;\n\n if (this._value) {\n resolve(this._value);\n }\n });\n }\n\n /**\n * @param {T} value\n */\n resolve(value) {\n if (this._value) {\n throw new Error('Already resolved.');\n }\n\n this._value = value;\n\n if (this._resolve) {\n this._resolve(value);\n }\n }\n\n /**\n * @return {!Promise}\n */\n toPromise() {\n return this._promise;\n }\n}\n","import CustomElementInternals from './CustomElementInternals.js';\nimport DocumentConstructionObserver from './DocumentConstructionObserver.js';\nimport Deferred from './Deferred.js';\nimport * as Utilities from './Utilities.js';\n\n/**\n * @unrestricted\n */\nexport default class CustomElementRegistry {\n\n /**\n * @param {!CustomElementInternals} internals\n */\n constructor(internals) {\n /**\n * @private\n * @type {boolean}\n */\n this._elementDefinitionIsRunning = false;\n\n /**\n * @private\n * @type {!CustomElementInternals}\n */\n this._internals = internals;\n\n /**\n * @private\n * @type {!Map>}\n */\n this._whenDefinedDeferred = new Map();\n\n /**\n * The default flush callback triggers the document walk synchronously.\n * @private\n * @type {!Function}\n */\n this._flushCallback = fn => fn();\n\n /**\n * @private\n * @type {boolean}\n */\n this._flushPending = false;\n\n /**\n * @private\n * @type {!Array}\n */\n this._unflushedLocalNames = [];\n\n /**\n * @private\n * @type {!DocumentConstructionObserver}\n */\n this._documentConstructionObserver = new DocumentConstructionObserver(internals, document);\n }\n\n /**\n * @param {string} localName\n * @param {!Function} constructor\n */\n define(localName, constructor) {\n if (!(constructor instanceof Function)) {\n throw new TypeError('Custom element constructors must be functions.');\n }\n\n if (!Utilities.isValidCustomElementName(localName)) {\n throw new SyntaxError(`The element name '${localName}' is not valid.`);\n }\n\n if (this._internals.localNameToDefinition(localName)) {\n throw new Error(`A custom element with name '${localName}' has already been defined.`);\n }\n\n if (this._elementDefinitionIsRunning) {\n throw new Error('A custom element is already being defined.');\n }\n this._elementDefinitionIsRunning = true;\n\n let connectedCallback;\n let disconnectedCallback;\n let adoptedCallback;\n let attributeChangedCallback;\n let observedAttributes;\n try {\n /** @type {!Object} */\n const prototype = constructor.prototype;\n if (!(prototype instanceof Object)) {\n throw new TypeError('The custom element constructor\\'s prototype is not an object.');\n }\n\n function getCallback(name) {\n const callbackValue = prototype[name];\n if (callbackValue !== undefined && !(callbackValue instanceof Function)) {\n throw new Error(`The '${name}' callback must be a function.`);\n }\n return callbackValue;\n }\n\n connectedCallback = getCallback('connectedCallback');\n disconnectedCallback = getCallback('disconnectedCallback');\n adoptedCallback = getCallback('adoptedCallback');\n attributeChangedCallback = getCallback('attributeChangedCallback');\n observedAttributes = constructor['observedAttributes'] || [];\n } catch (e) {\n return;\n } finally {\n this._elementDefinitionIsRunning = false;\n }\n\n const definition = {\n localName,\n constructor,\n connectedCallback,\n disconnectedCallback,\n adoptedCallback,\n attributeChangedCallback,\n observedAttributes,\n constructionStack: [],\n };\n\n this._internals.setDefinition(localName, definition);\n\n this._unflushedLocalNames.push(localName);\n\n // If we've already called the flush callback and it hasn't called back yet,\n // don't call it again.\n if (!this._flushPending) {\n this._flushPending = true;\n this._flushCallback(() => this._flush());\n }\n }\n\n _flush() {\n // If no new definitions were defined, don't attempt to flush. This could\n // happen if a flush callback keeps the function it is given and calls it\n // multiple times.\n if (this._flushPending === false) return;\n\n this._flushPending = false;\n this._internals.patchAndUpgradeTree(document);\n\n while (this._unflushedLocalNames.length > 0) {\n const localName = this._unflushedLocalNames.shift();\n const deferred = this._whenDefinedDeferred.get(localName);\n if (deferred) {\n deferred.resolve(undefined);\n }\n }\n }\n\n /**\n * @param {string} localName\n * @return {Function|undefined}\n */\n get(localName) {\n const definition = this._internals.localNameToDefinition(localName);\n if (definition) {\n return definition.constructor;\n }\n\n return undefined;\n }\n\n /**\n * @param {string} localName\n * @return {!Promise}\n */\n whenDefined(localName) {\n if (!Utilities.isValidCustomElementName(localName)) {\n return Promise.reject(new SyntaxError(`'${localName}' is not a valid custom element name.`));\n }\n\n const prior = this._whenDefinedDeferred.get(localName);\n if (prior) {\n return prior.toPromise();\n }\n\n const deferred = new Deferred();\n this._whenDefinedDeferred.set(localName, deferred);\n\n const definition = this._internals.localNameToDefinition(localName);\n // Resolve immediately only if the given local name has a definition *and*\n // the full document walk to upgrade elements with that local name has\n // already happened.\n if (definition && this._unflushedLocalNames.indexOf(localName) === -1) {\n deferred.resolve(undefined);\n }\n\n return deferred.toPromise();\n }\n\n polyfillWrapFlushCallback(outer) {\n this._documentConstructionObserver.disconnect();\n const inner = this._flushCallback;\n this._flushCallback = flush => outer(() => inner(flush));\n }\n}\n\n// Closure compiler exports.\nwindow['CustomElementRegistry'] = CustomElementRegistry;\nCustomElementRegistry.prototype['define'] = CustomElementRegistry.prototype.define;\nCustomElementRegistry.prototype['get'] = CustomElementRegistry.prototype.get;\nCustomElementRegistry.prototype['whenDefined'] = CustomElementRegistry.prototype.whenDefined;\nCustomElementRegistry.prototype['polyfillWrapFlushCallback'] = CustomElementRegistry.prototype.polyfillWrapFlushCallback;\n","import * as Env from '../Environment.js';\nimport * as EnvProxy from '../EnvironmentProxy.js';\nimport CustomElementInternals from '../CustomElementInternals.js';\nimport CEState from '../CustomElementState.js';\nimport AlreadyConstructedMarker from '../AlreadyConstructedMarker.js';\n\n/**\n * @param {!CustomElementInternals} internals\n */\nexport default function(internals) {\n window['HTMLElement'] = (function() {\n /**\n * @type {function(new: HTMLElement): !HTMLElement}\n */\n function HTMLElement() {\n // This should really be `new.target` but `new.target` can't be emulated\n // in ES5. Assuming the user keeps the default value of the constructor's\n // prototype's `constructor` property, this is equivalent.\n /** @type {!Function} */\n const constructor = this.constructor;\n\n const definition = internals.constructorToDefinition(constructor);\n if (!definition) {\n throw new Error('The custom element being constructed was not registered with `customElements`.');\n }\n\n const constructionStack = definition.constructionStack;\n\n if (constructionStack.length === 0) {\n const element = EnvProxy.createElement(document, definition.localName);\n Object.setPrototypeOf(element, constructor.prototype);\n element.__CE_state = CEState.custom;\n element.__CE_definition = definition;\n internals.patch(element);\n return element;\n }\n\n const lastIndex = constructionStack.length - 1;\n const element = constructionStack[lastIndex];\n if (element === AlreadyConstructedMarker) {\n throw new Error('The HTMLElement constructor was either called reentrantly for this constructor or called multiple times.');\n }\n constructionStack[lastIndex] = AlreadyConstructedMarker;\n\n Object.setPrototypeOf(element, constructor.prototype);\n internals.patch(/** @type {!HTMLElement} */ (element));\n\n return element;\n }\n\n HTMLElement.prototype = Env.HTMLElement.proto;\n\n return HTMLElement;\n })();\n};\n","/**\n * @license\n * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n */\n\nimport CustomElementInternals from './CustomElementInternals.js';\nimport CustomElementRegistry from './CustomElementRegistry.js';\n\nimport PatchHTMLElement from './Patch/HTMLElement.js';\nimport PatchDocument from './Patch/Document.js';\nimport PatchNode from './Patch/Node.js';\nimport PatchElement from './Patch/Element.js';\n\nconst priorCustomElements = window['customElements'];\n\nif (!priorCustomElements ||\n priorCustomElements['forcePolyfill'] ||\n (typeof priorCustomElements['define'] != 'function') ||\n (typeof priorCustomElements['get'] != 'function')) {\n /** @type {!CustomElementInternals} */\n const internals = new CustomElementInternals();\n\n PatchHTMLElement(internals);\n PatchDocument(internals);\n PatchNode(internals);\n PatchElement(internals);\n\n // The main document is always associated with the registry.\n document.__CE_hasRegistry = true;\n\n /** @type {!CustomElementRegistry} */\n const customElements = new CustomElementRegistry(internals);\n\n Object.defineProperty(window, 'customElements', {\n configurable: true,\n enumerable: true,\n value: customElements,\n });\n}\n","import CustomElementInternals from '../../CustomElementInternals.js';\nimport * as Utilities from '../../Utilities.js';\n\n/**\n * @typedef {{\n * prepend: !function(...(!Node|string)),\n * append: !function(...(!Node|string)),\n * }}\n */\nlet ParentNodeNativeMethods;\n\n/**\n * @param {!CustomElementInternals} internals\n * @param {!Object} destination\n * @param {!ParentNodeNativeMethods} builtIn\n */\nexport default function(internals, destination, builtIn) {\n /**\n * @param {...(!Node|string)} nodes\n */\n destination['prepend'] = function(...nodes) {\n // TODO: Fix this for when one of `nodes` is a DocumentFragment!\n const connectedBefore = /** @type {!Array} */ (nodes.filter(node => {\n // DocumentFragments are not connected and will not be added to the list.\n return node instanceof Node && Utilities.isConnected(node);\n }));\n\n builtIn.prepend.apply(this, nodes);\n\n for (let i = 0; i < connectedBefore.length; i++) {\n internals.disconnectTree(connectedBefore[i]);\n }\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node instanceof Element) {\n internals.connectTree(node);\n }\n }\n }\n };\n\n /**\n * @param {...(!Node|string)} nodes\n */\n destination['append'] = function(...nodes) {\n // TODO: Fix this for when one of `nodes` is a DocumentFragment!\n const connectedBefore = /** @type {!Array} */ (nodes.filter(node => {\n // DocumentFragments are not connected and will not be added to the list.\n return node instanceof Node && Utilities.isConnected(node);\n }));\n\n builtIn.append.apply(this, nodes);\n\n for (let i = 0; i < connectedBefore.length; i++) {\n internals.disconnectTree(connectedBefore[i]);\n }\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node instanceof Element) {\n internals.connectTree(node);\n }\n }\n }\n };\n};\n","import * as Env from '../Environment.js';\nimport * as EnvProxy from '../EnvironmentProxy.js';\nimport CustomElementInternals from '../CustomElementInternals.js';\nimport * as Utilities from '../Utilities.js';\n\nimport PatchParentNode from './Interface/ParentNode.js';\n\n/**\n * @param {!CustomElementInternals} internals\n */\nexport default function(internals) {\n Utilities.setPropertyUnchecked(Document.prototype, 'createElement',\n /**\n * @this {Document}\n * @param {string} localName\n * @return {!Element}\n */\n function(localName) {\n // Only create custom elements if this document is associated with the registry.\n if (this.__CE_hasRegistry) {\n const definition = internals.localNameToDefinition(localName);\n if (definition) {\n return new (definition.constructor)();\n }\n }\n\n const result = /** @type {!Element} */\n (EnvProxy.createElement(this, localName));\n internals.patch(result);\n return result;\n });\n\n Utilities.setPropertyUnchecked(Document.prototype, 'importNode',\n /**\n * @this {Document}\n * @param {!Node} node\n * @param {boolean=} deep\n * @return {!Node}\n */\n function(node, deep) {\n const clone = EnvProxy.importNode(this, node, deep);\n // Only create custom elements if this document is associated with the registry.\n if (!this.__CE_hasRegistry) {\n internals.patchTree(clone);\n } else {\n internals.patchAndUpgradeTree(clone);\n }\n return clone;\n });\n\n const NS_HTML = \"http://www.w3.org/1999/xhtml\";\n\n Utilities.setPropertyUnchecked(Document.prototype, 'createElementNS',\n /**\n * @this {Document}\n * @param {?string} namespace\n * @param {string} localName\n * @return {!Element}\n */\n function(namespace, localName) {\n // Only create custom elements if this document is associated with the registry.\n if (this.__CE_hasRegistry && (namespace === null || namespace === NS_HTML)) {\n const definition = internals.localNameToDefinition(localName);\n if (definition) {\n return new (definition.constructor)();\n }\n }\n\n const result = /** @type {!Element} */\n (EnvProxy.createElementNS(this, namespace, localName));\n internals.patch(result);\n return result;\n });\n\n PatchParentNode(internals, Document.prototype, {\n prepend: (Env.Document.prepend || {}).value,\n append: (Env.Document.append || {}).value,\n });\n};\n","import * as Env from '../Environment.js';\nimport * as EnvProxy from '../EnvironmentProxy.js';\nimport CustomElementInternals from '../CustomElementInternals.js';\nimport * as Utilities from '../Utilities.js';\n\n/**\n * @param {!CustomElementInternals} internals\n */\nexport default function(internals) {\n // `Node#nodeValue` is implemented on `Attr`.\n // `Node#textContent` is implemented on `Attr`, `Element`.\n\n Utilities.setPropertyUnchecked(Node.prototype, 'insertBefore',\n /**\n * @this {Node}\n * @param {!Node} node\n * @param {?Node} refNode\n * @return {!Node}\n */\n function(node, refNode) {\n if (node instanceof DocumentFragment) {\n const insertedNodes = Array.prototype.slice.apply(EnvProxy.childNodes(node));\n const nativeResult = EnvProxy.insertBefore(this, node, refNode);\n\n // DocumentFragments can't be connected, so `disconnectTree` will never\n // need to be called on a DocumentFragment's children after inserting it.\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < insertedNodes.length; i++) {\n internals.connectTree(insertedNodes[i]);\n }\n }\n\n return nativeResult;\n }\n\n const nodeWasConnected = Utilities.isConnected(node);\n const nativeResult = EnvProxy.insertBefore(this, node, refNode);\n\n if (nodeWasConnected) {\n internals.disconnectTree(node);\n }\n\n if (Utilities.isConnected(this)) {\n internals.connectTree(node);\n }\n\n return nativeResult;\n });\n\n Utilities.setPropertyUnchecked(Node.prototype, 'appendChild',\n /**\n * @this {Node}\n * @param {!Node} node\n * @return {!Node}\n */\n function(node) {\n if (node instanceof DocumentFragment) {\n const insertedNodes = Array.prototype.slice.apply(EnvProxy.childNodes(node));\n const nativeResult = EnvProxy.appendChild(this, node);\n\n // DocumentFragments can't be connected, so `disconnectTree` will never\n // need to be called on a DocumentFragment's children after inserting it.\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < insertedNodes.length; i++) {\n internals.connectTree(insertedNodes[i]);\n }\n }\n\n return nativeResult;\n }\n\n const nodeWasConnected = Utilities.isConnected(node);\n const nativeResult = EnvProxy.appendChild(this, node);\n\n if (nodeWasConnected) {\n internals.disconnectTree(node);\n }\n\n if (Utilities.isConnected(this)) {\n internals.connectTree(node);\n }\n\n return nativeResult;\n });\n\n Utilities.setPropertyUnchecked(Node.prototype, 'cloneNode',\n /**\n * @this {Node}\n * @param {boolean=} deep\n * @return {!Node}\n */\n function(deep) {\n const clone = EnvProxy.cloneNode(this, deep);\n // Only create custom elements if this element's owner document is\n // associated with the registry.\n if (!this.ownerDocument.__CE_hasRegistry) {\n internals.patchTree(clone);\n } else {\n internals.patchAndUpgradeTree(clone);\n }\n return clone;\n });\n\n Utilities.setPropertyUnchecked(Node.prototype, 'removeChild',\n /**\n * @this {Node}\n * @param {!Node} node\n * @return {!Node}\n */\n function(node) {\n const nodeWasConnected = Utilities.isConnected(node);\n const nativeResult = EnvProxy.removeChild(this, node);\n\n if (nodeWasConnected) {\n internals.disconnectTree(node);\n }\n\n return nativeResult;\n });\n\n Utilities.setPropertyUnchecked(Node.prototype, 'replaceChild',\n /**\n * @this {Node}\n * @param {!Node} nodeToInsert\n * @param {!Node} nodeToRemove\n * @return {!Node}\n */\n function(nodeToInsert, nodeToRemove) {\n if (nodeToInsert instanceof DocumentFragment) {\n const insertedNodes = Array.prototype.slice.apply(EnvProxy.childNodes(nodeToInsert));\n const nativeResult = EnvProxy.replaceChild(this, nodeToInsert, nodeToRemove);\n\n // DocumentFragments can't be connected, so `disconnectTree` will never\n // need to be called on a DocumentFragment's children after inserting it.\n\n if (Utilities.isConnected(this)) {\n internals.disconnectTree(nodeToRemove);\n for (let i = 0; i < insertedNodes.length; i++) {\n internals.connectTree(insertedNodes[i]);\n }\n }\n\n return nativeResult;\n }\n\n const nodeToInsertWasConnected = Utilities.isConnected(nodeToInsert);\n const nativeResult = EnvProxy.replaceChild(this, nodeToInsert, nodeToRemove);\n const thisIsConnected = Utilities.isConnected(this);\n\n if (thisIsConnected) {\n internals.disconnectTree(nodeToRemove);\n }\n\n if (nodeToInsertWasConnected) {\n internals.disconnectTree(nodeToInsert);\n }\n\n if (thisIsConnected) {\n internals.connectTree(nodeToInsert);\n }\n\n return nativeResult;\n });\n\n\n function patch_textContent(destination, baseDescriptor) {\n Object.defineProperty(destination, 'textContent', {\n enumerable: baseDescriptor.enumerable,\n configurable: true,\n get: baseDescriptor.get,\n set: /** @this {Node} */ function(assignedValue) {\n // If this is a text node then there are no nodes to disconnect.\n if (this.nodeType === Node.TEXT_NODE) {\n baseDescriptor.set.call(this, assignedValue);\n return;\n }\n\n let removedNodes = undefined;\n // Checking for `firstChild` is faster than reading `childNodes.length`\n // to compare with 0.\n if (EnvProxy.firstChild(this)) {\n // Using `childNodes` is faster than `children`, even though we only\n // care about elements.\n const childNodes = EnvProxy.childNodes(this);\n const childNodesLength = childNodes.length;\n if (childNodesLength > 0 && Utilities.isConnected(this)) {\n // Copying an array by iterating is faster than using slice.\n removedNodes = new Array(childNodesLength);\n for (let i = 0; i < childNodesLength; i++) {\n removedNodes[i] = childNodes[i];\n }\n }\n }\n\n baseDescriptor.set.call(this, assignedValue);\n\n if (removedNodes) {\n for (let i = 0; i < removedNodes.length; i++) {\n internals.disconnectTree(removedNodes[i]);\n }\n }\n },\n });\n }\n\n if (Env.Node.textContent && Env.Node.textContent.get) {\n patch_textContent(Node.prototype, Env.Node.textContent);\n } else {\n internals.addPatch(function(element) {\n patch_textContent(element, {\n enumerable: true,\n configurable: true,\n // NOTE: This implementation of the `textContent` getter assumes that\n // text nodes' `textContent` getter will not be patched.\n get: /** @this {Node} */ function() {\n /** @type {!Array} */\n const parts = [];\n\n const childNodes = EnvProxy.childNodes(this);\n for (let i = 0; i < childNodes.length; i++) {\n parts.push(childNodes[i].textContent);\n }\n\n return parts.join('');\n },\n set: /** @this {Node} */ function(assignedValue) {\n let child;\n while (child = EnvProxy.firstChild(this)) {\n EnvProxy.removeChild(this, child);\n }\n EnvProxy.appendChild(this, EnvProxy.createTextNode(document, assignedValue));\n },\n });\n });\n }\n};\n","import CustomElementInternals from '../../CustomElementInternals.js';\nimport * as Utilities from '../../Utilities.js';\n\n/**\n * @typedef {{\n * before: !function(...(!Node|string)),\n * after: !function(...(!Node|string)),\n * replaceWith: !function(...(!Node|string)),\n * remove: !function(),\n * }}\n */\nlet ChildNodeNativeMethods;\n\n/**\n * @param {!CustomElementInternals} internals\n * @param {!Object} destination\n * @param {!ChildNodeNativeMethods} builtIn\n */\nexport default function(internals, destination, builtIn) {\n /**\n * @param {...(!Node|string)} nodes\n */\n destination['before'] = function(...nodes) {\n // TODO: Fix this for when one of `nodes` is a DocumentFragment!\n const connectedBefore = /** @type {!Array} */ (nodes.filter(node => {\n // DocumentFragments are not connected and will not be added to the list.\n return node instanceof Node && Utilities.isConnected(node);\n }));\n\n builtIn.before.apply(this, nodes);\n\n for (let i = 0; i < connectedBefore.length; i++) {\n internals.disconnectTree(connectedBefore[i]);\n }\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node instanceof Element) {\n internals.connectTree(node);\n }\n }\n }\n };\n\n /**\n * @param {...(!Node|string)} nodes\n */\n destination['after'] = function(...nodes) {\n // TODO: Fix this for when one of `nodes` is a DocumentFragment!\n const connectedBefore = /** @type {!Array} */ (nodes.filter(node => {\n // DocumentFragments are not connected and will not be added to the list.\n return node instanceof Node && Utilities.isConnected(node);\n }));\n\n builtIn.after.apply(this, nodes);\n\n for (let i = 0; i < connectedBefore.length; i++) {\n internals.disconnectTree(connectedBefore[i]);\n }\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node instanceof Element) {\n internals.connectTree(node);\n }\n }\n }\n };\n\n /**\n * @param {...(!Node|string)} nodes\n */\n destination['replaceWith'] = function(...nodes) {\n // TODO: Fix this for when one of `nodes` is a DocumentFragment!\n const connectedBefore = /** @type {!Array} */ (nodes.filter(node => {\n // DocumentFragments are not connected and will not be added to the list.\n return node instanceof Node && Utilities.isConnected(node);\n }));\n\n const wasConnected = Utilities.isConnected(this);\n\n builtIn.replaceWith.apply(this, nodes);\n\n for (let i = 0; i < connectedBefore.length; i++) {\n internals.disconnectTree(connectedBefore[i]);\n }\n\n if (wasConnected) {\n internals.disconnectTree(this);\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node instanceof Element) {\n internals.connectTree(node);\n }\n }\n }\n };\n\n destination['remove'] = function() {\n const wasConnected = Utilities.isConnected(this);\n\n builtIn.remove.call(this);\n\n if (wasConnected) {\n internals.disconnectTree(this);\n }\n };\n};\n","import * as Env from '../Environment.js';\nimport * as EnvProxy from '../EnvironmentProxy.js';\nimport CustomElementInternals from '../CustomElementInternals.js';\nimport CEState from '../CustomElementState.js';\nimport * as Utilities from '../Utilities.js';\n\nimport PatchParentNode from './Interface/ParentNode.js';\nimport PatchChildNode from './Interface/ChildNode.js';\n\n/**\n * @param {!CustomElementInternals} internals\n */\nexport default function(internals) {\n if (Env.Element.attachShadow) {\n Utilities.setPropertyUnchecked(Element.prototype, 'attachShadow',\n /**\n * @this {Element}\n * @param {!{mode: string}} init\n * @return {ShadowRoot}\n */\n function(init) {\n const shadowRoot = EnvProxy.attachShadow(this, init);\n this.__CE_shadowRoot = shadowRoot;\n return shadowRoot;\n });\n } else {\n console.warn('Custom Elements: `Element#attachShadow` was not patched.');\n }\n\n\n function patch_innerHTML(destination, baseDescriptor) {\n Object.defineProperty(destination, 'innerHTML', {\n enumerable: baseDescriptor.enumerable,\n configurable: true,\n get: baseDescriptor.get,\n set: /** @this {Element} */ function(htmlString) {\n const isConnected = Utilities.isConnected(this);\n\n // NOTE: In IE11, when using the native `innerHTML` setter, all nodes\n // that were previously descendants of the context element have all of\n // their children removed as part of the set - the entire subtree is\n // 'disassembled'. This work around walks the subtree *before* using the\n // native setter.\n /** @type {!Array|undefined} */\n let removedElements = undefined;\n if (isConnected) {\n removedElements = [];\n Utilities.walkDeepDescendantElements(this, element => {\n if (element !== this) {\n removedElements.push(element);\n }\n });\n }\n\n baseDescriptor.set.call(this, htmlString);\n\n if (removedElements) {\n for (let i = 0; i < removedElements.length; i++) {\n const element = removedElements[i];\n if (element.__CE_state === CEState.custom) {\n internals.disconnectedCallback(element);\n }\n }\n }\n\n // Only create custom elements if this element's owner document is\n // associated with the registry.\n if (!this.ownerDocument.__CE_hasRegistry) {\n internals.patchTree(this);\n } else {\n internals.patchAndUpgradeTree(this);\n }\n return htmlString;\n },\n });\n }\n\n if (Env.Element.innerHTML && Env.Element.innerHTML.get) {\n patch_innerHTML(Element.prototype, Env.Element.innerHTML);\n } else if (Env.HTMLElement.innerHTML && Env.HTMLElement.innerHTML.get) {\n patch_innerHTML(HTMLElement.prototype, Env.HTMLElement.innerHTML);\n } else {\n // In this case, `innerHTML` has no exposed getter but still exists. Rather\n // than using the environment proxy, we have to get and set it directly.\n\n /** @type {HTMLDivElement} */\n const rawDiv = EnvProxy.createElement(document, 'div');\n\n internals.addPatch(function(element) {\n patch_innerHTML(element, {\n enumerable: true,\n configurable: true,\n // Implements getting `innerHTML` by performing an unpatched `cloneNode`\n // of the element and returning the resulting element's `innerHTML`.\n // TODO: Is this too expensive?\n get: /** @this {Element} */ function() {\n return EnvProxy.cloneNode(this, true).innerHTML;\n },\n // Implements setting `innerHTML` by creating an unpatched element,\n // setting `innerHTML` of that element and replacing the target\n // element's children with those of the unpatched element.\n set: /** @this {Element} */ function(assignedValue) {\n // NOTE: re-route to `content` for `template` elements.\n // We need to do this because `template.appendChild` does not\n // route into `template.content`.\n /** @type {!Node} */\n const content =\n (EnvProxy.localName(this) === 'template')\n ? EnvProxy.content(/** @type {!HTMLTemplateElement} */ (this))\n : this;\n rawDiv.innerHTML = assignedValue;\n\n while (EnvProxy.childNodes(content).length > 0) {\n EnvProxy.removeChild(content, content.childNodes[0]);\n }\n while (EnvProxy.childNodes(rawDiv).length > 0) {\n EnvProxy.appendChild(content, rawDiv.childNodes[0]);\n }\n },\n });\n });\n }\n\n\n Utilities.setPropertyUnchecked(Element.prototype, 'setAttribute',\n /**\n * @this {Element}\n * @param {string} name\n * @param {string} newValue\n */\n function(name, newValue) {\n // Fast path for non-custom elements.\n if (this.__CE_state !== CEState.custom) {\n return EnvProxy.setAttribute(this, name, newValue);\n }\n\n const oldValue = EnvProxy.getAttribute(this, name);\n EnvProxy.setAttribute(this, name, newValue);\n newValue = EnvProxy.getAttribute(this, name);\n internals.attributeChangedCallback(this, name, oldValue, newValue, null);\n });\n\n Utilities.setPropertyUnchecked(Element.prototype, 'setAttributeNS',\n /**\n * @this {Element}\n * @param {?string} namespace\n * @param {string} name\n * @param {string} newValue\n */\n function(namespace, name, newValue) {\n // Fast path for non-custom elements.\n if (this.__CE_state !== CEState.custom) {\n return EnvProxy.setAttributeNS(this, namespace, name, newValue);\n }\n\n const oldValue = EnvProxy.getAttributeNS(this, namespace, name);\n EnvProxy.setAttributeNS(this, namespace, name, newValue);\n newValue = EnvProxy.getAttributeNS(this, namespace, name);\n internals.attributeChangedCallback(this, name, oldValue, newValue, namespace);\n });\n\n Utilities.setPropertyUnchecked(Element.prototype, 'removeAttribute',\n /**\n * @this {Element}\n * @param {string} name\n */\n function(name) {\n // Fast path for non-custom elements.\n if (this.__CE_state !== CEState.custom) {\n return EnvProxy.removeAttribute(this, name);\n }\n\n const oldValue = EnvProxy.getAttribute(this, name);\n EnvProxy.removeAttribute(this, name);\n if (oldValue !== null) {\n internals.attributeChangedCallback(this, name, oldValue, null, null);\n }\n });\n\n Utilities.setPropertyUnchecked(Element.prototype, 'removeAttributeNS',\n /**\n * @this {Element}\n * @param {?string} namespace\n * @param {string} name\n */\n function(namespace, name) {\n // Fast path for non-custom elements.\n if (this.__CE_state !== CEState.custom) {\n return EnvProxy.removeAttributeNS(this, namespace, name);\n }\n\n const oldValue = EnvProxy.getAttributeNS(this, namespace, name);\n EnvProxy.removeAttributeNS(this, namespace, name);\n // In older browsers, `Element#getAttributeNS` may return the empty string\n // instead of null if the attribute does not exist. For details, see;\n // https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttributeNS#Notes\n const newValue = EnvProxy.getAttributeNS(this, namespace, name);\n if (oldValue !== newValue) {\n internals.attributeChangedCallback(this, name, oldValue, newValue, namespace);\n }\n });\n\n\n function patch_insertAdjacentElement(destination, baseMethod) {\n Utilities.setPropertyUnchecked(destination, 'insertAdjacentElement',\n /**\n * @this {Element}\n * @param {string} where\n * @param {!Element} element\n * @return {?Element}\n */\n function(where, element) {\n const wasConnected = Utilities.isConnected(element);\n const insertedElement = /** @type {!Element} */\n (baseMethod.call(this, where, element));\n\n if (wasConnected) {\n internals.disconnectTree(element);\n }\n\n if (Utilities.isConnected(insertedElement)) {\n internals.connectTree(element);\n }\n return insertedElement;\n });\n }\n\n if (Env.HTMLElement.insertAdjacentElement && Env.HTMLElement.insertAdjacentElement.value) {\n patch_insertAdjacentElement(HTMLElement.prototype, Env.HTMLElement.insertAdjacentElement.value);\n } else if (Env.Element.insertAdjacentElement && Env.Element.insertAdjacentElement.value) {\n patch_insertAdjacentElement(Element.prototype, Env.Element.insertAdjacentElement.value);\n } else {\n console.warn('Custom Elements: `Element#insertAdjacentElement` was not patched.');\n }\n\n\n PatchParentNode(internals, Element.prototype, {\n prepend: (Env.Element.prepend || {}).value,\n append: (Env.Element.append || {}).value,\n });\n\n PatchChildNode(internals, Element.prototype, {\n before: (Env.Element.before || {}).value,\n after: (Env.Element.after || {}).value,\n replaceWith: (Env.Element.replaceWith || {}).value,\n remove: (Env.Element.remove || {}).value,\n });\n};\n"]} \ No newline at end of file +{"version":3,"sources":["src/AlreadyConstructedMarker.js","src/Environment.js","src/EnvironmentProxy.js","src/CustomElementInternals.js","src/Utilities.js","src/CustomElementState.js","src/DocumentConstructionObserver.js","src/Deferred.js","src/CustomElementRegistry.js","src/Patch/HTMLElement.js","src/custom-elements.js","src/Patch/Interface/ParentNode.js","src/Patch/Document.js","src/Patch/Node.js","src/Patch/Interface/ChildNode.js","src/Patch/Element.js"],"names":["$jscompDefaultExport","AlreadyConstructedMarker","getDescriptor$$module$$src$Environment","o","p","Object","getOwnPropertyDescriptor","envDocument_proto","window","envDocument","append","getDescriptor","prepend","envElement_proto","envElement","after","attachShadow","before","innerHTML","insertAdjacentElement","remove","replaceWith","envHTMLElement_proto","envHTMLElement","HTMLElement","envMutationObserver","envMutationObserver_proto","envNode_proto","envNode","textContent","getter$$module$$src$EnvironmentProxy","descriptor","get","undefined","method$$module$$src$EnvironmentProxy","value","createElementMethod","method","createElement","createElementNSMethod","createElementNS","createTextNodeMethod","createTextNode","importNodeMethod","importNode","readyStateGetter","getter","readyState","attachShadowMethod","Element$$module$$src$Environment.attachShadow","getAttributeMethod","getAttribute","getAttributeNSMethod","getAttributeNS","localNameGetter","localName","removeAttributeMethod","removeAttribute","removeAttributeNSMethod","removeAttributeNS","setAttributeMethod","setAttribute","setAttributeNSMethod","setAttributeNS","contentGetter","content","envHTMLTemplateElement","envHTMLTemplateElement_proto","observeMethod","observe","disconnectMethod","disconnect","addedNodesGetter","addedNodes","envMutationRecord","envMutationRecord_proto","addEventListenerMethod","addEventListener","addEventListener$$module$$src$EnvironmentProxy","node","callback","call","type","options","appendChildMethod","appendChild","childNodesGetter","childNodes","cloneNodeMethod","cloneNode","firstChildGetter","firstChild","insertBeforeMethod","insertBefore","isConnectedGetter","isConnected","nextSiblingGetter","nextSibling","nodeTypeGetter","nodeType","parentNodeGetter","parentNode","removeChildMethod","removeChild","replaceChildMethod","replaceChild","reservedTagList","Set","isValidCustomElementName$$module$$src$Utilities","isValidCustomElementName","reserved","has","validForm","test","isConnected$$module$$src$Utilities","nativeValue","current","__CE_isImportDocument","Document","ShadowRoot","host","nextSiblingOrAncestorSibling$$module$$src$Utilities","nextSiblingOrAncestorSibling","root","start","walkDeepDescendantElements$$module$$src$Utilities","walkDeepDescendantElements","visitedImports","Node","ELEMENT_NODE","element","name","import","add","child","shadowRoot","__CE_shadowRoot","setPropertyUnchecked$$module$$src$Utilities","setPropertyUnchecked","destination","constructor","CustomElementInternals","_localNameToDefinition","Map","_constructorToDefinition","_patches","_hasPatches","setDefinition","definition","set","addPatch","listener","push","patchTree","patch","__CE_patched","i","length","connectTree","elements","custom","__CE_state","connectedCallback","upgradeElement","disconnectTree","disconnectedCallback","patchAndUpgradeTree","gatherElements","__CE_hasRegistry","__CE_documentLoadHandled","delete","localNameToDefinition","constructionStack","result","Error","pop","e","failed","__CE_definition","attributeChangedCallback","observedAttributes","oldValue","newValue","namespace","indexOf","DocumentConstructionObserver","internals","doc","_internals","_document","_observer","_handleMutations","bind","childList","subtree","mutations","j","Deferred","_resolve","_value","_promise","Promise","resolve","CustomElementRegistry","_elementDefinitionIsRunning","_whenDefinedDeferred","_flushCallback","this._flushCallback","fn","_flushPending","_unflushedLocalNames","_documentConstructionObserver","document","define","Function","TypeError","SyntaxError","adoptedCallback","getCallback","callbackValue","prototype","_flush","shift","deferred","whenDefined","reject","prior","polyfillWrapFlushCallback","outer","inner","flush","$jscompDefaultExport$$module$$src$Patch$HTMLElement","setPrototypeOf","lastIndex","$jscompDefaultExport$$module$$src$Patch$Interface$ParentNode","builtIn","connectedBefore","nodes","filter","apply","Element","$jscompDefaultExport$$module$$src$Patch$Document","deep","clone","NS_HTML","Document$$module$$src$Environment.prepend","Document$$module$$src$Environment.append","$jscompDefaultExport$$module$$src$Patch$Node","patch_textContent","baseDescriptor","defineProperty","enumerable","configurable","assignedValue","TEXT_NODE","removedNodes","childNodesLength","Array","refNode","DocumentFragment","insertedNodes","slice","nativeResult","nodeWasConnected","ownerDocument","nodeToInsert","nodeToRemove","nodeToInsertWasConnected","thisIsConnected","Node$$module$$src$Environment.textContent","Node$$module$$src$Environment.textContent.get","parts","join","$jscompDefaultExport$$module$$src$Patch$Interface$ChildNode","Element$$module$$src$Environment.before","Element$$module$$src$Environment.after","Element$$module$$src$Environment.replaceWith","Element$$module$$src$Environment.remove","wasConnected","$jscompDefaultExport$$module$$src$Patch$Element","patch_innerHTML","htmlString","removedElements","patch_insertAdjacentElement","baseMethod","where","insertedElement","init","console","warn","Element$$module$$src$Environment.innerHTML","Element$$module$$src$Environment.innerHTML.get","HTMLElement$$module$$src$Environment.innerHTML","HTMLElement$$module$$src$Environment.innerHTML.get","rawDiv","Element$$module$$src$Environment.insertAdjacentElement","Element$$module$$src$Environment.insertAdjacentElement.value","Element$$module$$src$Environment.prepend","Element$$module$$src$Environment.append","priorCustomElements","customElements"],"mappings":"A;aASA,IAAAA,EAAe,IAFfC,QAAA,EAAA,E,CCPsBC,QAAA,EAAA,CAACC,CAAD,CAAIC,CAAJ,CAAU,CAAA,MAAAC,OAAAC,yBAAA,CAAgCH,CAAhC,CAAmCC,CAAnC,CAAA,CAGhC,IAAMG,EADcC,MAAAC,SACM,UAA1B,CAMEC,GAAQC,CAAAD,CAAcH,CAAdG,CAAiCA,QAAjCA,CANV,CAWEE,GAASD,CAAAC,CAAcL,CAAdK,CAAiCA,SAAjCA,CAXX,CAgBMC,EADaL,MAAAM,QACM,UAhBzB,CAqBEC,GAAOJ,CAAAI,CAAcF,CAAdE,CAAgCA,OAAhCA,CArBT,CAsBEL,GAAQC,CAAAD,CAAcG,CAAd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+Nb,CAAe0L,CAAf,CArOiC,C;;;;;;;;;ALMnC,IAAMiH,EAAsBnS,MAAA,eAE5B,IAAKmS,CAAAA,CAAL,EACKA,CAAA,cADL,EAE8C,UAF9C,EAEM,MAAOA,EAAA,OAFb,EAG2C,UAH3C,EAGM,MAAOA,EAAA,IAHb,CAGwD,CAEtD,IAAMjH,EAAY,IPrBL7C,CMKA7I,GCkBb,EEjBaA,GFkBb,EGpBaA,GHqBb,EKjBaA,GLkBb,EAGAoN,SAAA5C,iBAAA,CAA4B,CAAA,CAG5B,KAAMoI,eAAiB,IF5BVjG,CE4BU,CAA0BjB,CAA1B,CAEvBrL,OAAAqP,eAAA,CAAsBlP,MAAtB,CAA8B,gBAA9B,CAAgD,CAC9CoP,aAAc,CAAA,CADgC,CAE9CD,WAAY,CAAA,CAFkC,CAG9CxN,MAAOyQ,cAHuC,CAAhD,CAfsD","file":"custom-elements.min.js","sourcesContent":["/**\n * This class exists only to work around Closure's lack of a way to describe\n * singletons. It represents the 'already constructed marker' used in custom\n * element construction stacks.\n *\n * https://html.spec.whatwg.org/#concept-already-constructed-marker\n */\nclass AlreadyConstructedMarker {}\n\nexport default new AlreadyConstructedMarker();\n","const getDescriptor = (o, p) => Object.getOwnPropertyDescriptor(o, p);\n\nconst envDocument = window['Document'];\nconst envDocument_proto = envDocument['prototype'];\nexport const Document = {\n self: envDocument,\n // Closure's renaming breaks if this property is named `prototype`.\n proto: envDocument_proto,\n\n append: getDescriptor(envDocument_proto, 'append'),\n createElement: getDescriptor(envDocument_proto, 'createElement'),\n createElementNS: getDescriptor(envDocument_proto, 'createElementNS'),\n createTextNode: getDescriptor(envDocument_proto, 'createTextNode'),\n importNode: getDescriptor(envDocument_proto, 'importNode'),\n prepend: getDescriptor(envDocument_proto, 'prepend'),\n readyState: getDescriptor(envDocument_proto, 'readyState'),\n};\n\nconst envElement = window['Element'];\nconst envElement_proto = envElement['prototype'];\nexport const Element = {\n self: envElement,\n proto: envElement_proto,\n\n after: getDescriptor(envElement_proto, 'after'),\n append: getDescriptor(envElement_proto, 'append'),\n attachShadow: getDescriptor(envElement_proto, 'attachShadow'),\n before: getDescriptor(envElement_proto, 'before'),\n getAttribute: getDescriptor(envElement_proto, 'getAttribute'),\n getAttributeNS: getDescriptor(envElement_proto, 'getAttributeNS'),\n innerHTML: getDescriptor(envElement_proto, 'innerHTML'),\n insertAdjacentElement: getDescriptor(envElement_proto, 'insertAdjacentElement'),\n localName: getDescriptor(envElement_proto, 'localName'),\n prepend: getDescriptor(envElement_proto, 'prepend'),\n remove: getDescriptor(envElement_proto, 'remove'),\n removeAttribute: getDescriptor(envElement_proto, 'removeAttribute'),\n removeAttributeNS: getDescriptor(envElement_proto, 'removeAttributeNS'),\n replaceWith: getDescriptor(envElement_proto, 'replaceWith'),\n setAttribute: getDescriptor(envElement_proto, 'setAttribute'),\n setAttributeNS: getDescriptor(envElement_proto, 'setAttributeNS'),\n};\n\nconst envHTMLElement = window['HTMLElement'];\nconst envHTMLElement_proto = envHTMLElement['prototype'];\nexport const HTMLElement = {\n self: envHTMLElement,\n proto: envHTMLElement_proto,\n\n innerHTML: getDescriptor(envHTMLElement_proto, 'innerHTML'),\n};\n\nconst envHTMLTemplateElement = window['HTMLTemplateElement'];\nconst envHTMLTemplateElement_proto = envHTMLTemplateElement['prototype'];\nexport const HTMLTemplateElement = {\n self: envHTMLTemplateElement,\n proto: envHTMLTemplateElement_proto,\n\n content: getDescriptor(envHTMLTemplateElement_proto, 'content'),\n};\n\nconst envMutationObserver = window['MutationObserver'];\nconst envMutationObserver_proto = envMutationObserver['prototype'];\nexport const MutationObserver = {\n self: envMutationObserver,\n proto: envMutationObserver_proto,\n\n disconnect: getDescriptor(envMutationObserver_proto, 'disconnect'),\n observe: getDescriptor(envMutationObserver_proto, 'observe'),\n};\n\nconst envMutationRecord = window['MutationRecord'];\nconst envMutationRecord_proto = envMutationRecord['prototype'];\nexport const MutationRecord = {\n self: envMutationRecord,\n proto: envMutationRecord_proto,\n\n addedNodes: getDescriptor(envMutationRecord_proto, 'addedNodes'),\n};\n\nconst envNode = window['Node'];\nconst envNode_proto = envNode['prototype'];\nexport const Node = {\n self: envNode,\n proto: envNode_proto,\n\n addEventListener: getDescriptor(envNode_proto, 'addEventListener'),\n appendChild: getDescriptor(envNode_proto, 'appendChild'),\n childNodes: getDescriptor(envNode_proto, 'childNodes'),\n cloneNode: getDescriptor(envNode_proto, 'cloneNode'),\n firstChild: getDescriptor(envNode_proto, 'firstChild'),\n insertBefore: getDescriptor(envNode_proto, 'insertBefore'),\n isConnected: getDescriptor(envNode_proto, 'isConnected'),\n nextSibling: getDescriptor(envNode_proto, 'nextSibling'),\n nodeType: getDescriptor(envNode_proto, 'nodeType'),\n parentNode: getDescriptor(envNode_proto, 'parentNode'),\n removeChild: getDescriptor(envNode_proto, 'removeChild'),\n replaceChild: getDescriptor(envNode_proto, 'replaceChild'),\n textContent: getDescriptor(envNode_proto, 'textContent'),\n};\n","import * as Env from './Environment.js';\n\nconst getter = descriptor => descriptor ? descriptor.get : () => undefined;\nconst method = descriptor => descriptor ? descriptor.value : () => undefined;\n\n// Document\n\nconst createElementMethod = method(Env.Document.createElement);\nexport const createElement = (doc, localName) => createElementMethod.call(doc, localName);\n\nconst createElementNSMethod = method(Env.Document.createElementNS);\nexport const createElementNS = (doc, namespace, qualifiedName) => createElementNSMethod.call(doc, namespace, qualifiedName);\n\nconst createTextNodeMethod = method(Env.Document.createTextNode);\nexport const createTextNode = (doc, localName) => createTextNodeMethod.call(doc, localName);\n\nconst importNodeMethod = method(Env.Document.importNode);\nexport const importNode = (doc, node, deep) => importNodeMethod.call(doc, node, deep);\n\nconst readyStateGetter = getter(Env.Document.readyState);\nexport const readyState = doc => readyStateGetter.call(doc);\n\n// Element\n\nconst attachShadowMethod = method(Env.Element.attachShadow);\nexport const attachShadow = (node, options) => attachShadowMethod.call(node, options);\n\nconst getAttributeMethod = method(Env.Element.getAttribute);\nexport const getAttribute = (node, name) => getAttributeMethod.call(node, name);\n\nconst getAttributeNSMethod = method(Env.Element.getAttributeNS);\nexport const getAttributeNS = (node, ns, name) => getAttributeNSMethod.call(node, ns, name);\n\nconst localNameGetter = getter(Env.Element.localName);\nexport const localName = node => localNameGetter.call(node);\n\nconst removeAttributeMethod = method(Env.Element.removeAttribute);\nexport const removeAttribute = (node, name) => removeAttributeMethod.call(node, name);\n\nconst removeAttributeNSMethod = method(Env.Element.removeAttributeNS);\nexport const removeAttributeNS = (node, ns, name) => removeAttributeNSMethod.call(node, ns, name);\n\nconst setAttributeMethod = method(Env.Element.setAttribute);\nexport const setAttribute = (node, name, value) => setAttributeMethod.call(node, name, value);\n\nconst setAttributeNSMethod = method(Env.Element.setAttributeNS);\nexport const setAttributeNS = (node, ns, name, value) => setAttributeNSMethod.call(node, ns, name, value);\n\n// HTMLTemplateElement\n\nconst contentGetter = getter(Env.HTMLTemplateElement.content);\nexport const content = node => contentGetter.call(node);\n\n// MutationObserver\n\nconst observeMethod = method(Env.MutationObserver.observe);\nexport const observe = (mutationObserver, target, options) => observeMethod.call(mutationObserver, target, options);\n\nconst disconnectMethod = method(Env.MutationObserver.disconnect);\nexport const disconnect = mutationObserver => disconnectMethod.call(mutationObserver);\n\n// MutationRecord\n\nconst addedNodesGetter = getter(Env.MutationRecord.addedNodes);\nexport const addedNodes = node => addedNodesGetter.call(node);\n\n// Node\n\nconst addEventListenerMethod = method(Env.Node.addEventListener);\nexport const addEventListener = (node, type, callback, options) => addEventListenerMethod.call(node, type, callback, options);\n\nconst appendChildMethod = method(Env.Node.appendChild);\nexport const appendChild = (node, deep) => appendChildMethod.call(node, deep);\n\nconst childNodesGetter = getter(Env.Node.childNodes);\nexport const childNodes = node => childNodesGetter.call(node);\n\nconst cloneNodeMethod = method(Env.Node.cloneNode);\nexport const cloneNode = (node, deep) => cloneNodeMethod.call(node, deep);\n\nconst firstChildGetter = getter(Env.Node.firstChild);\nexport const firstChild = node => firstChildGetter.call(node);\n\nconst insertBeforeMethod = method(Env.Node.insertBefore);\nexport const insertBefore = (node, newChild, refChild) => insertBeforeMethod.call(node, newChild, refChild);\n\nconst isConnectedGetter = getter(Env.Node.isConnected);\nexport const isConnected = node => isConnectedGetter.call(node);\n\nconst nextSiblingGetter = getter(Env.Node.nextSibling);\nexport const nextSibling = node => nextSiblingGetter.call(node);\n\nconst nodeTypeGetter = getter(Env.Node.nodeType);\nexport const nodeType = node => nodeTypeGetter.call(node);\n\nconst parentNodeGetter = getter(Env.Node.parentNode);\nexport const parentNode = node => parentNodeGetter.call(node);\n\nconst removeChildMethod = method(Env.Node.removeChild);\nexport const removeChild = (node, deep) => removeChildMethod.call(node, deep);\n\nconst replaceChildMethod = method(Env.Node.replaceChild);\nexport const replaceChild = (node, newChild, oldChild) => replaceChildMethod.call(node, newChild, oldChild);\n","import * as EnvProxy from './EnvironmentProxy.js';\nimport * as Utilities from './Utilities.js';\nimport CEState from './CustomElementState.js';\n\nexport default class CustomElementInternals {\n constructor() {\n /** @type {!Map} */\n this._localNameToDefinition = new Map();\n\n /** @type {!Map} */\n this._constructorToDefinition = new Map();\n\n /** @type {!Array} */\n this._patches = [];\n\n /** @type {boolean} */\n this._hasPatches = false;\n }\n\n /**\n * @param {string} localName\n * @param {!CustomElementDefinition} definition\n */\n setDefinition(localName, definition) {\n this._localNameToDefinition.set(localName, definition);\n this._constructorToDefinition.set(definition.constructor, definition);\n }\n\n /**\n * @param {string} localName\n * @return {!CustomElementDefinition|undefined}\n */\n localNameToDefinition(localName) {\n return this._localNameToDefinition.get(localName);\n }\n\n /**\n * @param {!Function} constructor\n * @return {!CustomElementDefinition|undefined}\n */\n constructorToDefinition(constructor) {\n return this._constructorToDefinition.get(constructor);\n }\n\n /**\n * @param {!function(!Node)} listener\n */\n addPatch(listener) {\n this._hasPatches = true;\n this._patches.push(listener);\n }\n\n /**\n * @param {!Node} node\n */\n patchTree(node) {\n if (!this._hasPatches) return;\n\n Utilities.walkDeepDescendantElements(node, element => this.patch(element));\n }\n\n /**\n * @param {!Node} node\n */\n patch(node) {\n if (!this._hasPatches) return;\n\n if (node.__CE_patched) return;\n node.__CE_patched = true;\n\n for (let i = 0; i < this._patches.length; i++) {\n this._patches[i](node);\n }\n }\n\n /**\n * @param {!Node} root\n */\n connectTree(root) {\n const elements = [];\n\n Utilities.walkDeepDescendantElements(root, element => elements.push(element));\n\n for (let i = 0; i < elements.length; i++) {\n const element = elements[i];\n if (element.__CE_state === CEState.custom) {\n this.connectedCallback(element);\n } else {\n this.upgradeElement(element);\n }\n }\n }\n\n /**\n * @param {!Node} root\n */\n disconnectTree(root) {\n const elements = [];\n\n Utilities.walkDeepDescendantElements(root, element => elements.push(element));\n\n for (let i = 0; i < elements.length; i++) {\n const element = elements[i];\n if (element.__CE_state === CEState.custom) {\n this.disconnectedCallback(element);\n }\n }\n }\n\n /**\n * Upgrades all uncustomized custom elements at and below a root node for\n * which there is a definition. When custom element reaction callbacks are\n * assumed to be called synchronously (which, by the current DOM / HTML spec\n * definitions, they are *not*), callbacks for both elements customized\n * synchronously by the parser and elements being upgraded occur in the same\n * relative order.\n *\n * NOTE: This function, when used to simulate the construction of a tree that\n * is already created but not customized (i.e. by the parser), does *not*\n * prevent the element from reading the 'final' (true) state of the tree. For\n * example, the element, during truly synchronous parsing / construction would\n * see that it contains no children as they have not yet been inserted.\n * However, this function does not modify the tree, the element will\n * (incorrectly) have children. Additionally, self-modification restrictions\n * for custom element constructors imposed by the DOM spec are *not* enforced.\n *\n *\n * The following nested list shows the steps extending down from the HTML\n * spec's parsing section that cause elements to be synchronously created and\n * upgraded:\n *\n * The \"in body\" insertion mode:\n * https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody\n * - Switch on token:\n * .. other cases ..\n * -> Any other start tag\n * - [Insert an HTML element](below) for the token.\n *\n * Insert an HTML element:\n * https://html.spec.whatwg.org/multipage/syntax.html#insert-an-html-element\n * - Insert a foreign element for the token in the HTML namespace:\n * https://html.spec.whatwg.org/multipage/syntax.html#insert-a-foreign-element\n * - Create an element for a token:\n * https://html.spec.whatwg.org/multipage/syntax.html#create-an-element-for-the-token\n * - Will execute script flag is true?\n * - (Element queue pushed to the custom element reactions stack.)\n * - Create an element:\n * https://dom.spec.whatwg.org/#concept-create-element\n * - Sync CE flag is true?\n * - Constructor called.\n * - Self-modification restrictions enforced.\n * - Sync CE flag is false?\n * - (Upgrade reaction enqueued.)\n * - Attributes appended to element.\n * (`attributeChangedCallback` reactions enqueued.)\n * - Will execute script flag is true?\n * - (Element queue popped from the custom element reactions stack.\n * Reactions in the popped stack are invoked.)\n * - (Element queue pushed to the custom element reactions stack.)\n * - Insert the element:\n * https://dom.spec.whatwg.org/#concept-node-insert\n * - Shadow-including descendants are connected. During parsing\n * construction, there are no shadow-*excluding* descendants.\n * However, the constructor may have validly attached a shadow\n * tree to itself and added descendants to that shadow tree.\n * (`connectedCallback` reactions enqueued.)\n * - (Element queue popped from the custom element reactions stack.\n * Reactions in the popped stack are invoked.)\n *\n * @param {!Node} root\n * @param {!Set=} visitedImports\n */\n patchAndUpgradeTree(root, visitedImports = new Set()) {\n const elements = [];\n\n const gatherElements = element => {\n if (EnvProxy.localName(element) === 'link' && EnvProxy.getAttribute(element, 'rel') === 'import') {\n // The HTML Imports polyfill sets a descendant element of the link to\n // the `import` property, specifically this is *not* a Document.\n const importNode = /** @type {?Node} */ (element.import);\n\n if (importNode instanceof Node && importNode.readyState === 'complete') {\n importNode.__CE_isImportDocument = true;\n\n // Connected links are associated with the registry.\n importNode.__CE_hasRegistry = true;\n } else {\n // If this link's import root is not available, its contents can't be\n // walked. Wait for 'load' and walk it when it's ready.\n EnvProxy.addEventListener(element, 'load', () => {\n const importNode = /** @type {!Node} */ (element.import);\n\n if (importNode.__CE_documentLoadHandled) return;\n importNode.__CE_documentLoadHandled = true;\n\n importNode.__CE_isImportDocument = true;\n\n // Connected links are associated with the registry.\n importNode.__CE_hasRegistry = true;\n\n // Clone the `visitedImports` set that was populated sync during\n // the `patchAndUpgradeTree` call that caused this 'load' handler to\n // be added. Then, remove *this* link's import node so that we can\n // walk that import again, even if it was partially walked later\n // during the same `patchAndUpgradeTree` call.\n const clonedVisitedImports = new Set(visitedImports);\n visitedImports.delete(importNode);\n\n this.patchAndUpgradeTree(importNode, visitedImports);\n });\n }\n } else {\n elements.push(element);\n }\n };\n\n // `walkDeepDescendantElements` populates (and internally checks against)\n // `visitedImports` when traversing a loaded import.\n Utilities.walkDeepDescendantElements(root, gatherElements, visitedImports);\n\n if (this._hasPatches) {\n for (let i = 0; i < elements.length; i++) {\n this.patch(elements[i]);\n }\n }\n\n for (let i = 0; i < elements.length; i++) {\n this.upgradeElement(elements[i]);\n }\n }\n\n /**\n * @param {!Element} element\n */\n upgradeElement(element) {\n const currentState = element.__CE_state;\n if (currentState !== undefined) return;\n\n const definition = this.localNameToDefinition(element.localName);\n if (!definition) return;\n\n definition.constructionStack.push(element);\n\n const constructor = definition.constructor;\n try {\n try {\n let result = new (constructor)();\n if (result !== element) {\n throw new Error('The custom element constructor did not produce the element being upgraded.');\n }\n } finally {\n definition.constructionStack.pop();\n }\n } catch (e) {\n element.__CE_state = CEState.failed;\n throw e;\n }\n\n element.__CE_state = CEState.custom;\n element.__CE_definition = definition;\n\n if (definition.attributeChangedCallback) {\n const observedAttributes = definition.observedAttributes;\n for (let i = 0; i < observedAttributes.length; i++) {\n const name = observedAttributes[i];\n const value = EnvProxy.getAttribute(element, name);\n if (value !== null) {\n this.attributeChangedCallback(element, name, null, value, null);\n }\n }\n }\n\n if (Utilities.isConnected(element)) {\n this.connectedCallback(element);\n }\n }\n\n /**\n * @param {!Element} element\n */\n connectedCallback(element) {\n const definition = element.__CE_definition;\n if (definition.connectedCallback) {\n definition.connectedCallback.call(element);\n }\n }\n\n /**\n * @param {!Element} element\n */\n disconnectedCallback(element) {\n const definition = element.__CE_definition;\n if (definition.disconnectedCallback) {\n definition.disconnectedCallback.call(element);\n }\n }\n\n /**\n * @param {!Element} element\n * @param {string} name\n * @param {?string} oldValue\n * @param {?string} newValue\n * @param {?string} namespace\n */\n attributeChangedCallback(element, name, oldValue, newValue, namespace) {\n const definition = element.__CE_definition;\n if (\n definition.attributeChangedCallback &&\n definition.observedAttributes.indexOf(name) > -1\n ) {\n definition.attributeChangedCallback.call(element, name, oldValue, newValue, namespace);\n }\n }\n}\n","import * as EnvProxy from './EnvironmentProxy.js';\n\nconst reservedTagList = new Set([\n 'annotation-xml',\n 'color-profile',\n 'font-face',\n 'font-face-src',\n 'font-face-uri',\n 'font-face-format',\n 'font-face-name',\n 'missing-glyph',\n]);\n\n/**\n * @param {string} localName\n * @returns {boolean}\n */\nexport function isValidCustomElementName(localName) {\n const reserved = reservedTagList.has(localName);\n const validForm = /^[a-z][.0-9_a-z]*-[\\-.0-9_a-z]*$/.test(localName);\n return !reserved && validForm;\n}\n\n/**\n * @private\n * @param {!Node} node\n * @return {boolean}\n */\nexport function isConnected(node) {\n // Use `Node#isConnected`, if defined.\n const nativeValue = EnvProxy.isConnected(node);\n if (nativeValue !== undefined) {\n return nativeValue;\n }\n\n /** @type {?Node|undefined} */\n let current = node;\n while (current && !(current.__CE_isImportDocument || current instanceof Document)) {\n current = EnvProxy.parentNode(current) || (window.ShadowRoot && current instanceof ShadowRoot ? current.host : undefined);\n }\n return !!(current && (current.__CE_isImportDocument || current instanceof Document));\n}\n\n/**\n * @param {!Node} root\n * @param {!Node} start\n * @return {?Node}\n */\nfunction nextSiblingOrAncestorSibling(root, start) {\n let node = start;\n while (node && node !== root && !EnvProxy.nextSibling(node)) {\n node = EnvProxy.parentNode(node);\n }\n return (!node || node === root) ? null : EnvProxy.nextSibling(node);\n}\n\n/**\n * @param {!Node} root\n * @param {!Node} start\n * @return {?Node}\n */\nfunction nextNode(root, start) {\n return EnvProxy.firstChild(start) || nextSiblingOrAncestorSibling(root, start);\n}\n\n/**\n * @param {!Node} root\n * @param {!function(!Element)} callback\n * @param {!Set=} visitedImports\n */\nexport function walkDeepDescendantElements(root, callback, visitedImports = new Set()) {\n let node = root;\n while (node) {\n if (EnvProxy.nodeType(node) === Node.ELEMENT_NODE) {\n const element = /** @type {!Element} */(node);\n\n callback(element);\n\n const localName = EnvProxy.localName(element);\n if (localName === 'link' && EnvProxy.getAttribute(element, 'rel') === 'import') {\n // If this import (polyfilled or not) has it's root node available,\n // walk it.\n const importNode = /** @type {!Node} */ (element.import);\n if (importNode instanceof Node && !visitedImports.has(importNode)) {\n // Prevent multiple walks of the same import root.\n visitedImports.add(importNode);\n\n for (let child = EnvProxy.firstChild(importNode); child; child = EnvProxy.nextSibling(child)) {\n walkDeepDescendantElements(child, callback, visitedImports);\n }\n }\n\n // Ignore descendants of import links to prevent attempting to walk the\n // elements created by the HTML Imports polyfill that we just walked\n // above.\n node = nextSiblingOrAncestorSibling(root, element);\n continue;\n } else if (localName === 'template') {\n // Ignore descendants of templates. There shouldn't be any descendants\n // because they will be moved into `.content` during construction in\n // browsers that support template but, in case they exist and are still\n // waiting to be moved by a polyfill, they will be ignored.\n node = nextSiblingOrAncestorSibling(root, element);\n continue;\n }\n\n // Walk shadow roots.\n const shadowRoot = element.__CE_shadowRoot;\n if (shadowRoot) {\n for (let child = EnvProxy.firstChild(shadowRoot); child; child = EnvProxy.nextSibling(child)) {\n walkDeepDescendantElements(child, callback, visitedImports);\n }\n }\n }\n\n node = nextNode(root, node);\n }\n}\n\n/**\n * Used to suppress Closure's \"Modifying the prototype is only allowed if the\n * constructor is in the same scope\" warning without using\n * `@suppress {newCheckTypes, duplicate}` because `newCheckTypes` is too broad.\n *\n * @param {!Object} destination\n * @param {string} name\n * @param {*} value\n */\nexport function setPropertyUnchecked(destination, name, value) {\n destination[name] = value;\n}\n","/**\n * @enum {number}\n */\nconst CustomElementState = {\n custom: 1,\n failed: 2,\n};\n\nexport default CustomElementState;\n","import * as Env from './Environment.js';\nimport * as EnvProxy from './EnvironmentProxy.js';\nimport CustomElementInternals from './CustomElementInternals.js';\n\nexport default class DocumentConstructionObserver {\n constructor(internals, doc) {\n /**\n * @type {!CustomElementInternals}\n */\n this._internals = internals;\n\n /**\n * @type {!Document}\n */\n this._document = doc;\n\n /**\n * @type {MutationObserver|undefined}\n */\n this._observer = undefined;\n\n\n // Simulate tree construction for all currently accessible nodes in the\n // document.\n this._internals.patchAndUpgradeTree(this._document);\n\n if (EnvProxy.readyState(this._document) === 'loading') {\n this._observer = new Env.MutationObserver.self(this._handleMutations.bind(this));\n\n // Nodes created by the parser are given to the observer *before* the next\n // task runs. Inline scripts are run in a new task. This means that the\n // observer will be able to handle the newly parsed nodes before the inline\n // script is run.\n EnvProxy.observe(this._observer, this._document, {\n childList: true,\n subtree: true,\n });\n }\n }\n\n disconnect() {\n if (this._observer) {\n EnvProxy.disconnect(this._observer);\n }\n }\n\n /**\n * @param {!Array} mutations\n */\n _handleMutations(mutations) {\n // Once the document's `readyState` is 'interactive' or 'complete', all new\n // nodes created within that document will be the result of script and\n // should be handled by patching.\n const readyState = EnvProxy.readyState(this._document);\n if (readyState === 'interactive' || readyState === 'complete') {\n this.disconnect();\n }\n\n for (let i = 0; i < mutations.length; i++) {\n const addedNodes = EnvProxy.addedNodes(mutations[i]);\n for (let j = 0; j < addedNodes.length; j++) {\n const node = addedNodes[j];\n this._internals.patchAndUpgradeTree(node);\n }\n }\n }\n}\n","/**\n * @template T\n */\nexport default class Deferred {\n constructor() {\n /**\n * @private\n * @type {T|undefined}\n */\n this._value = undefined;\n\n /**\n * @private\n * @type {Function|undefined}\n */\n this._resolve = undefined;\n\n /**\n * @private\n * @type {!Promise}\n */\n this._promise = new Promise(resolve => {\n this._resolve = resolve;\n\n if (this._value) {\n resolve(this._value);\n }\n });\n }\n\n /**\n * @param {T} value\n */\n resolve(value) {\n if (this._value) {\n throw new Error('Already resolved.');\n }\n\n this._value = value;\n\n if (this._resolve) {\n this._resolve(value);\n }\n }\n\n /**\n * @return {!Promise}\n */\n toPromise() {\n return this._promise;\n }\n}\n","import CustomElementInternals from './CustomElementInternals.js';\nimport DocumentConstructionObserver from './DocumentConstructionObserver.js';\nimport Deferred from './Deferred.js';\nimport * as Utilities from './Utilities.js';\n\n/**\n * @unrestricted\n */\nexport default class CustomElementRegistry {\n\n /**\n * @param {!CustomElementInternals} internals\n */\n constructor(internals) {\n /**\n * @private\n * @type {boolean}\n */\n this._elementDefinitionIsRunning = false;\n\n /**\n * @private\n * @type {!CustomElementInternals}\n */\n this._internals = internals;\n\n /**\n * @private\n * @type {!Map>}\n */\n this._whenDefinedDeferred = new Map();\n\n /**\n * The default flush callback triggers the document walk synchronously.\n * @private\n * @type {!Function}\n */\n this._flushCallback = fn => fn();\n\n /**\n * @private\n * @type {boolean}\n */\n this._flushPending = false;\n\n /**\n * @private\n * @type {!Array}\n */\n this._unflushedLocalNames = [];\n\n /**\n * @private\n * @type {!DocumentConstructionObserver}\n */\n this._documentConstructionObserver = new DocumentConstructionObserver(internals, document);\n }\n\n /**\n * @param {string} localName\n * @param {!Function} constructor\n */\n define(localName, constructor) {\n if (!(constructor instanceof Function)) {\n throw new TypeError('Custom element constructors must be functions.');\n }\n\n if (!Utilities.isValidCustomElementName(localName)) {\n throw new SyntaxError(`The element name '${localName}' is not valid.`);\n }\n\n if (this._internals.localNameToDefinition(localName)) {\n throw new Error(`A custom element with name '${localName}' has already been defined.`);\n }\n\n if (this._elementDefinitionIsRunning) {\n throw new Error('A custom element is already being defined.');\n }\n this._elementDefinitionIsRunning = true;\n\n let connectedCallback;\n let disconnectedCallback;\n let adoptedCallback;\n let attributeChangedCallback;\n let observedAttributes;\n try {\n /** @type {!Object} */\n const prototype = constructor.prototype;\n if (!(prototype instanceof Object)) {\n throw new TypeError('The custom element constructor\\'s prototype is not an object.');\n }\n\n function getCallback(name) {\n const callbackValue = prototype[name];\n if (callbackValue !== undefined && !(callbackValue instanceof Function)) {\n throw new Error(`The '${name}' callback must be a function.`);\n }\n return callbackValue;\n }\n\n connectedCallback = getCallback('connectedCallback');\n disconnectedCallback = getCallback('disconnectedCallback');\n adoptedCallback = getCallback('adoptedCallback');\n attributeChangedCallback = getCallback('attributeChangedCallback');\n observedAttributes = constructor['observedAttributes'] || [];\n } catch (e) {\n return;\n } finally {\n this._elementDefinitionIsRunning = false;\n }\n\n const definition = {\n localName,\n constructor,\n connectedCallback,\n disconnectedCallback,\n adoptedCallback,\n attributeChangedCallback,\n observedAttributes,\n constructionStack: [],\n };\n\n this._internals.setDefinition(localName, definition);\n\n this._unflushedLocalNames.push(localName);\n\n // If we've already called the flush callback and it hasn't called back yet,\n // don't call it again.\n if (!this._flushPending) {\n this._flushPending = true;\n this._flushCallback(() => this._flush());\n }\n }\n\n _flush() {\n // If no new definitions were defined, don't attempt to flush. This could\n // happen if a flush callback keeps the function it is given and calls it\n // multiple times.\n if (this._flushPending === false) return;\n\n this._flushPending = false;\n this._internals.patchAndUpgradeTree(document);\n\n while (this._unflushedLocalNames.length > 0) {\n const localName = this._unflushedLocalNames.shift();\n const deferred = this._whenDefinedDeferred.get(localName);\n if (deferred) {\n deferred.resolve(undefined);\n }\n }\n }\n\n /**\n * @param {string} localName\n * @return {Function|undefined}\n */\n get(localName) {\n const definition = this._internals.localNameToDefinition(localName);\n if (definition) {\n return definition.constructor;\n }\n\n return undefined;\n }\n\n /**\n * @param {string} localName\n * @return {!Promise}\n */\n whenDefined(localName) {\n if (!Utilities.isValidCustomElementName(localName)) {\n return Promise.reject(new SyntaxError(`'${localName}' is not a valid custom element name.`));\n }\n\n const prior = this._whenDefinedDeferred.get(localName);\n if (prior) {\n return prior.toPromise();\n }\n\n const deferred = new Deferred();\n this._whenDefinedDeferred.set(localName, deferred);\n\n const definition = this._internals.localNameToDefinition(localName);\n // Resolve immediately only if the given local name has a definition *and*\n // the full document walk to upgrade elements with that local name has\n // already happened.\n if (definition && this._unflushedLocalNames.indexOf(localName) === -1) {\n deferred.resolve(undefined);\n }\n\n return deferred.toPromise();\n }\n\n polyfillWrapFlushCallback(outer) {\n this._documentConstructionObserver.disconnect();\n const inner = this._flushCallback;\n this._flushCallback = flush => outer(() => inner(flush));\n }\n}\n\n// Closure compiler exports.\nwindow['CustomElementRegistry'] = CustomElementRegistry;\nCustomElementRegistry.prototype['define'] = CustomElementRegistry.prototype.define;\nCustomElementRegistry.prototype['get'] = CustomElementRegistry.prototype.get;\nCustomElementRegistry.prototype['whenDefined'] = CustomElementRegistry.prototype.whenDefined;\nCustomElementRegistry.prototype['polyfillWrapFlushCallback'] = CustomElementRegistry.prototype.polyfillWrapFlushCallback;\n","import * as Env from '../Environment.js';\nimport * as EnvProxy from '../EnvironmentProxy.js';\nimport CustomElementInternals from '../CustomElementInternals.js';\nimport CEState from '../CustomElementState.js';\nimport AlreadyConstructedMarker from '../AlreadyConstructedMarker.js';\n\n/**\n * @param {!CustomElementInternals} internals\n */\nexport default function(internals) {\n window['HTMLElement'] = (function() {\n /**\n * @type {function(new: HTMLElement): !HTMLElement}\n */\n function HTMLElement() {\n // This should really be `new.target` but `new.target` can't be emulated\n // in ES5. Assuming the user keeps the default value of the constructor's\n // prototype's `constructor` property, this is equivalent.\n /** @type {!Function} */\n const constructor = this.constructor;\n\n const definition = internals.constructorToDefinition(constructor);\n if (!definition) {\n throw new Error('The custom element being constructed was not registered with `customElements`.');\n }\n\n const constructionStack = definition.constructionStack;\n\n if (constructionStack.length === 0) {\n const element = EnvProxy.createElement(document, definition.localName);\n Object.setPrototypeOf(element, constructor.prototype);\n element.__CE_state = CEState.custom;\n element.__CE_definition = definition;\n internals.patch(element);\n return element;\n }\n\n const lastIndex = constructionStack.length - 1;\n const element = constructionStack[lastIndex];\n if (element === AlreadyConstructedMarker) {\n throw new Error('The HTMLElement constructor was either called reentrantly for this constructor or called multiple times.');\n }\n constructionStack[lastIndex] = AlreadyConstructedMarker;\n\n Object.setPrototypeOf(element, constructor.prototype);\n internals.patch(/** @type {!HTMLElement} */ (element));\n\n return element;\n }\n\n HTMLElement.prototype = Env.HTMLElement.proto;\n\n return HTMLElement;\n })();\n};\n","/**\n * @license\n * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n */\n\nimport CustomElementInternals from './CustomElementInternals.js';\nimport CustomElementRegistry from './CustomElementRegistry.js';\n\nimport PatchHTMLElement from './Patch/HTMLElement.js';\nimport PatchDocument from './Patch/Document.js';\nimport PatchNode from './Patch/Node.js';\nimport PatchElement from './Patch/Element.js';\n\nconst priorCustomElements = window['customElements'];\n\nif (!priorCustomElements ||\n priorCustomElements['forcePolyfill'] ||\n (typeof priorCustomElements['define'] != 'function') ||\n (typeof priorCustomElements['get'] != 'function')) {\n /** @type {!CustomElementInternals} */\n const internals = new CustomElementInternals();\n\n PatchHTMLElement(internals);\n PatchDocument(internals);\n PatchNode(internals);\n PatchElement(internals);\n\n // The main document is always associated with the registry.\n document.__CE_hasRegistry = true;\n\n /** @type {!CustomElementRegistry} */\n const customElements = new CustomElementRegistry(internals);\n\n Object.defineProperty(window, 'customElements', {\n configurable: true,\n enumerable: true,\n value: customElements,\n });\n}\n","import CustomElementInternals from '../../CustomElementInternals.js';\nimport * as Utilities from '../../Utilities.js';\n\n/**\n * @typedef {{\n * prepend: !function(...(!Node|string)),\n * append: !function(...(!Node|string)),\n * }}\n */\nlet ParentNodeNativeMethods;\n\n/**\n * @param {!CustomElementInternals} internals\n * @param {!Object} destination\n * @param {!ParentNodeNativeMethods} builtIn\n */\nexport default function(internals, destination, builtIn) {\n /**\n * @param {...(!Node|string)} nodes\n */\n destination['prepend'] = function(...nodes) {\n // TODO: Fix this for when one of `nodes` is a DocumentFragment!\n const connectedBefore = /** @type {!Array} */ (nodes.filter(node => {\n // DocumentFragments are not connected and will not be added to the list.\n return node instanceof Node && Utilities.isConnected(node);\n }));\n\n builtIn.prepend.apply(this, nodes);\n\n for (let i = 0; i < connectedBefore.length; i++) {\n internals.disconnectTree(connectedBefore[i]);\n }\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node instanceof Element) {\n internals.connectTree(node);\n }\n }\n }\n };\n\n /**\n * @param {...(!Node|string)} nodes\n */\n destination['append'] = function(...nodes) {\n // TODO: Fix this for when one of `nodes` is a DocumentFragment!\n const connectedBefore = /** @type {!Array} */ (nodes.filter(node => {\n // DocumentFragments are not connected and will not be added to the list.\n return node instanceof Node && Utilities.isConnected(node);\n }));\n\n builtIn.append.apply(this, nodes);\n\n for (let i = 0; i < connectedBefore.length; i++) {\n internals.disconnectTree(connectedBefore[i]);\n }\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node instanceof Element) {\n internals.connectTree(node);\n }\n }\n }\n };\n};\n","import * as Env from '../Environment.js';\nimport * as EnvProxy from '../EnvironmentProxy.js';\nimport CustomElementInternals from '../CustomElementInternals.js';\nimport * as Utilities from '../Utilities.js';\n\nimport PatchParentNode from './Interface/ParentNode.js';\n\n/**\n * @param {!CustomElementInternals} internals\n */\nexport default function(internals) {\n Utilities.setPropertyUnchecked(Document.prototype, 'createElement',\n /**\n * @this {Document}\n * @param {string} localName\n * @return {!Element}\n */\n function(localName) {\n // Only create custom elements if this document is associated with the registry.\n if (this.__CE_hasRegistry) {\n const definition = internals.localNameToDefinition(localName);\n if (definition) {\n return new (definition.constructor)();\n }\n }\n\n const result = /** @type {!Element} */\n (EnvProxy.createElement(this, localName));\n internals.patch(result);\n return result;\n });\n\n Utilities.setPropertyUnchecked(Document.prototype, 'importNode',\n /**\n * @this {Document}\n * @param {!Node} node\n * @param {boolean=} deep\n * @return {!Node}\n */\n function(node, deep) {\n const clone = EnvProxy.importNode(this, node, deep);\n // Only create custom elements if this document is associated with the registry.\n if (!this.__CE_hasRegistry) {\n internals.patchTree(clone);\n } else {\n internals.patchAndUpgradeTree(clone);\n }\n return clone;\n });\n\n const NS_HTML = \"http://www.w3.org/1999/xhtml\";\n\n Utilities.setPropertyUnchecked(Document.prototype, 'createElementNS',\n /**\n * @this {Document}\n * @param {?string} namespace\n * @param {string} localName\n * @return {!Element}\n */\n function(namespace, localName) {\n // Only create custom elements if this document is associated with the registry.\n if (this.__CE_hasRegistry && (namespace === null || namespace === NS_HTML)) {\n const definition = internals.localNameToDefinition(localName);\n if (definition) {\n return new (definition.constructor)();\n }\n }\n\n const result = /** @type {!Element} */\n (EnvProxy.createElementNS(this, namespace, localName));\n internals.patch(result);\n return result;\n });\n\n PatchParentNode(internals, Document.prototype, {\n prepend: (Env.Document.prepend || {}).value,\n append: (Env.Document.append || {}).value,\n });\n};\n","import * as Env from '../Environment.js';\nimport * as EnvProxy from '../EnvironmentProxy.js';\nimport CustomElementInternals from '../CustomElementInternals.js';\nimport * as Utilities from '../Utilities.js';\n\n/**\n * @param {!CustomElementInternals} internals\n */\nexport default function(internals) {\n // `Node#nodeValue` is implemented on `Attr`.\n // `Node#textContent` is implemented on `Attr`, `Element`.\n\n Utilities.setPropertyUnchecked(Node.prototype, 'insertBefore',\n /**\n * @this {Node}\n * @param {!Node} node\n * @param {?Node} refNode\n * @return {!Node}\n */\n function(node, refNode) {\n if (node instanceof DocumentFragment) {\n const insertedNodes = Array.prototype.slice.apply(EnvProxy.childNodes(node));\n const nativeResult = EnvProxy.insertBefore(this, node, refNode);\n\n // DocumentFragments can't be connected, so `disconnectTree` will never\n // need to be called on a DocumentFragment's children after inserting it.\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < insertedNodes.length; i++) {\n internals.connectTree(insertedNodes[i]);\n }\n }\n\n return nativeResult;\n }\n\n const nodeWasConnected = Utilities.isConnected(node);\n const nativeResult = EnvProxy.insertBefore(this, node, refNode);\n\n if (nodeWasConnected) {\n internals.disconnectTree(node);\n }\n\n if (Utilities.isConnected(this)) {\n internals.connectTree(node);\n }\n\n return nativeResult;\n });\n\n Utilities.setPropertyUnchecked(Node.prototype, 'appendChild',\n /**\n * @this {Node}\n * @param {!Node} node\n * @return {!Node}\n */\n function(node) {\n if (node instanceof DocumentFragment) {\n const insertedNodes = Array.prototype.slice.apply(EnvProxy.childNodes(node));\n const nativeResult = EnvProxy.appendChild(this, node);\n\n // DocumentFragments can't be connected, so `disconnectTree` will never\n // need to be called on a DocumentFragment's children after inserting it.\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < insertedNodes.length; i++) {\n internals.connectTree(insertedNodes[i]);\n }\n }\n\n return nativeResult;\n }\n\n const nodeWasConnected = Utilities.isConnected(node);\n const nativeResult = EnvProxy.appendChild(this, node);\n\n if (nodeWasConnected) {\n internals.disconnectTree(node);\n }\n\n if (Utilities.isConnected(this)) {\n internals.connectTree(node);\n }\n\n return nativeResult;\n });\n\n Utilities.setPropertyUnchecked(Node.prototype, 'cloneNode',\n /**\n * @this {Node}\n * @param {boolean=} deep\n * @return {!Node}\n */\n function(deep) {\n const clone = EnvProxy.cloneNode(this, deep);\n // Only create custom elements if this element's owner document is\n // associated with the registry.\n if (!this.ownerDocument.__CE_hasRegistry) {\n internals.patchTree(clone);\n } else {\n internals.patchAndUpgradeTree(clone);\n }\n return clone;\n });\n\n Utilities.setPropertyUnchecked(Node.prototype, 'removeChild',\n /**\n * @this {Node}\n * @param {!Node} node\n * @return {!Node}\n */\n function(node) {\n const nodeWasConnected = Utilities.isConnected(node);\n const nativeResult = EnvProxy.removeChild(this, node);\n\n if (nodeWasConnected) {\n internals.disconnectTree(node);\n }\n\n return nativeResult;\n });\n\n Utilities.setPropertyUnchecked(Node.prototype, 'replaceChild',\n /**\n * @this {Node}\n * @param {!Node} nodeToInsert\n * @param {!Node} nodeToRemove\n * @return {!Node}\n */\n function(nodeToInsert, nodeToRemove) {\n if (nodeToInsert instanceof DocumentFragment) {\n const insertedNodes = Array.prototype.slice.apply(EnvProxy.childNodes(nodeToInsert));\n const nativeResult = EnvProxy.replaceChild(this, nodeToInsert, nodeToRemove);\n\n // DocumentFragments can't be connected, so `disconnectTree` will never\n // need to be called on a DocumentFragment's children after inserting it.\n\n if (Utilities.isConnected(this)) {\n internals.disconnectTree(nodeToRemove);\n for (let i = 0; i < insertedNodes.length; i++) {\n internals.connectTree(insertedNodes[i]);\n }\n }\n\n return nativeResult;\n }\n\n const nodeToInsertWasConnected = Utilities.isConnected(nodeToInsert);\n const nativeResult = EnvProxy.replaceChild(this, nodeToInsert, nodeToRemove);\n const thisIsConnected = Utilities.isConnected(this);\n\n if (thisIsConnected) {\n internals.disconnectTree(nodeToRemove);\n }\n\n if (nodeToInsertWasConnected) {\n internals.disconnectTree(nodeToInsert);\n }\n\n if (thisIsConnected) {\n internals.connectTree(nodeToInsert);\n }\n\n return nativeResult;\n });\n\n\n function patch_textContent(destination, baseDescriptor) {\n Object.defineProperty(destination, 'textContent', {\n enumerable: baseDescriptor.enumerable,\n configurable: true,\n get: baseDescriptor.get,\n set: /** @this {Node} */ function(assignedValue) {\n // If this is a text node then there are no nodes to disconnect.\n if (this.nodeType === Node.TEXT_NODE) {\n baseDescriptor.set.call(this, assignedValue);\n return;\n }\n\n let removedNodes = undefined;\n // Checking for `firstChild` is faster than reading `childNodes.length`\n // to compare with 0.\n if (EnvProxy.firstChild(this)) {\n // Using `childNodes` is faster than `children`, even though we only\n // care about elements.\n const childNodes = EnvProxy.childNodes(this);\n const childNodesLength = childNodes.length;\n if (childNodesLength > 0 && Utilities.isConnected(this)) {\n // Copying an array by iterating is faster than using slice.\n removedNodes = new Array(childNodesLength);\n for (let i = 0; i < childNodesLength; i++) {\n removedNodes[i] = childNodes[i];\n }\n }\n }\n\n baseDescriptor.set.call(this, assignedValue);\n\n if (removedNodes) {\n for (let i = 0; i < removedNodes.length; i++) {\n internals.disconnectTree(removedNodes[i]);\n }\n }\n },\n });\n }\n\n if (Env.Node.textContent && Env.Node.textContent.get) {\n patch_textContent(Node.prototype, Env.Node.textContent);\n } else {\n internals.addPatch(function(element) {\n patch_textContent(element, {\n enumerable: true,\n configurable: true,\n // NOTE: This implementation of the `textContent` getter assumes that\n // text nodes' `textContent` getter will not be patched.\n get: /** @this {Node} */ function() {\n /** @type {!Array} */\n const parts = [];\n\n const childNodes = EnvProxy.childNodes(this);\n for (let i = 0; i < childNodes.length; i++) {\n parts.push(childNodes[i].textContent);\n }\n\n return parts.join('');\n },\n set: /** @this {Node} */ function(assignedValue) {\n let child;\n while (child = EnvProxy.firstChild(this)) {\n EnvProxy.removeChild(this, child);\n }\n EnvProxy.appendChild(this, EnvProxy.createTextNode(document, assignedValue));\n },\n });\n });\n }\n};\n","import CustomElementInternals from '../../CustomElementInternals.js';\nimport * as Utilities from '../../Utilities.js';\n\n/**\n * @typedef {{\n * before: !function(...(!Node|string)),\n * after: !function(...(!Node|string)),\n * replaceWith: !function(...(!Node|string)),\n * remove: !function(),\n * }}\n */\nlet ChildNodeNativeMethods;\n\n/**\n * @param {!CustomElementInternals} internals\n * @param {!Object} destination\n * @param {!ChildNodeNativeMethods} builtIn\n */\nexport default function(internals, destination, builtIn) {\n /**\n * @param {...(!Node|string)} nodes\n */\n destination['before'] = function(...nodes) {\n // TODO: Fix this for when one of `nodes` is a DocumentFragment!\n const connectedBefore = /** @type {!Array} */ (nodes.filter(node => {\n // DocumentFragments are not connected and will not be added to the list.\n return node instanceof Node && Utilities.isConnected(node);\n }));\n\n builtIn.before.apply(this, nodes);\n\n for (let i = 0; i < connectedBefore.length; i++) {\n internals.disconnectTree(connectedBefore[i]);\n }\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node instanceof Element) {\n internals.connectTree(node);\n }\n }\n }\n };\n\n /**\n * @param {...(!Node|string)} nodes\n */\n destination['after'] = function(...nodes) {\n // TODO: Fix this for when one of `nodes` is a DocumentFragment!\n const connectedBefore = /** @type {!Array} */ (nodes.filter(node => {\n // DocumentFragments are not connected and will not be added to the list.\n return node instanceof Node && Utilities.isConnected(node);\n }));\n\n builtIn.after.apply(this, nodes);\n\n for (let i = 0; i < connectedBefore.length; i++) {\n internals.disconnectTree(connectedBefore[i]);\n }\n\n if (Utilities.isConnected(this)) {\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node instanceof Element) {\n internals.connectTree(node);\n }\n }\n }\n };\n\n /**\n * @param {...(!Node|string)} nodes\n */\n destination['replaceWith'] = function(...nodes) {\n // TODO: Fix this for when one of `nodes` is a DocumentFragment!\n const connectedBefore = /** @type {!Array} */ (nodes.filter(node => {\n // DocumentFragments are not connected and will not be added to the list.\n return node instanceof Node && Utilities.isConnected(node);\n }));\n\n const wasConnected = Utilities.isConnected(this);\n\n builtIn.replaceWith.apply(this, nodes);\n\n for (let i = 0; i < connectedBefore.length; i++) {\n internals.disconnectTree(connectedBefore[i]);\n }\n\n if (wasConnected) {\n internals.disconnectTree(this);\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node instanceof Element) {\n internals.connectTree(node);\n }\n }\n }\n };\n\n destination['remove'] = function() {\n const wasConnected = Utilities.isConnected(this);\n\n builtIn.remove.call(this);\n\n if (wasConnected) {\n internals.disconnectTree(this);\n }\n };\n};\n","import * as Env from '../Environment.js';\nimport * as EnvProxy from '../EnvironmentProxy.js';\nimport CustomElementInternals from '../CustomElementInternals.js';\nimport CEState from '../CustomElementState.js';\nimport * as Utilities from '../Utilities.js';\n\nimport PatchParentNode from './Interface/ParentNode.js';\nimport PatchChildNode from './Interface/ChildNode.js';\n\n/**\n * @param {!CustomElementInternals} internals\n */\nexport default function(internals) {\n if (Env.Element.attachShadow) {\n Utilities.setPropertyUnchecked(Element.prototype, 'attachShadow',\n /**\n * @this {Element}\n * @param {!{mode: string}} init\n * @return {ShadowRoot}\n */\n function(init) {\n const shadowRoot = EnvProxy.attachShadow(this, init);\n this.__CE_shadowRoot = shadowRoot;\n return shadowRoot;\n });\n } else {\n console.warn('Custom Elements: `Element#attachShadow` was not patched.');\n }\n\n\n function patch_innerHTML(destination, baseDescriptor) {\n Object.defineProperty(destination, 'innerHTML', {\n enumerable: baseDescriptor.enumerable,\n configurable: true,\n get: baseDescriptor.get,\n set: /** @this {Element} */ function(htmlString) {\n const isConnected = Utilities.isConnected(this);\n\n // NOTE: In IE11, when using the native `innerHTML` setter, all nodes\n // that were previously descendants of the context element have all of\n // their children removed as part of the set - the entire subtree is\n // 'disassembled'. This work around walks the subtree *before* using the\n // native setter.\n /** @type {!Array|undefined} */\n let removedElements = undefined;\n if (isConnected) {\n removedElements = [];\n Utilities.walkDeepDescendantElements(this, element => {\n if (element !== this) {\n removedElements.push(element);\n }\n });\n }\n\n baseDescriptor.set.call(this, htmlString);\n\n if (removedElements) {\n for (let i = 0; i < removedElements.length; i++) {\n const element = removedElements[i];\n if (element.__CE_state === CEState.custom) {\n internals.disconnectedCallback(element);\n }\n }\n }\n\n // Only create custom elements if this element's owner document is\n // associated with the registry.\n if (!this.ownerDocument.__CE_hasRegistry) {\n internals.patchTree(this);\n } else {\n internals.patchAndUpgradeTree(this);\n }\n return htmlString;\n },\n });\n }\n\n if (Env.Element.innerHTML && Env.Element.innerHTML.get) {\n patch_innerHTML(Element.prototype, Env.Element.innerHTML);\n } else if (Env.HTMLElement.innerHTML && Env.HTMLElement.innerHTML.get) {\n patch_innerHTML(HTMLElement.prototype, Env.HTMLElement.innerHTML);\n } else {\n // In this case, `innerHTML` has no exposed getter but still exists. Rather\n // than using the environment proxy, we have to get and set it directly.\n\n /** @type {HTMLDivElement} */\n const rawDiv = EnvProxy.createElement(document, 'div');\n\n internals.addPatch(function(element) {\n patch_innerHTML(element, {\n enumerable: true,\n configurable: true,\n // Implements getting `innerHTML` by performing an unpatched `cloneNode`\n // of the element and returning the resulting element's `innerHTML`.\n // TODO: Is this too expensive?\n get: /** @this {Element} */ function() {\n return EnvProxy.cloneNode(this, true).innerHTML;\n },\n // Implements setting `innerHTML` by creating an unpatched element,\n // setting `innerHTML` of that element and replacing the target\n // element's children with those of the unpatched element.\n set: /** @this {Element} */ function(assignedValue) {\n // NOTE: re-route to `content` for `template` elements.\n // We need to do this because `template.appendChild` does not\n // route into `template.content`.\n /** @type {!Node} */\n const content =\n (EnvProxy.localName(this) === 'template')\n ? EnvProxy.content(/** @type {!HTMLTemplateElement} */ (this))\n : this;\n rawDiv.innerHTML = assignedValue;\n\n while (EnvProxy.childNodes(content).length > 0) {\n EnvProxy.removeChild(content, content.childNodes[0]);\n }\n while (EnvProxy.childNodes(rawDiv).length > 0) {\n EnvProxy.appendChild(content, rawDiv.childNodes[0]);\n }\n },\n });\n });\n }\n\n\n Utilities.setPropertyUnchecked(Element.prototype, 'setAttribute',\n /**\n * @this {Element}\n * @param {string} name\n * @param {string} newValue\n */\n function(name, newValue) {\n // Fast path for non-custom elements.\n if (this.__CE_state !== CEState.custom) {\n return EnvProxy.setAttribute(this, name, newValue);\n }\n\n const oldValue = EnvProxy.getAttribute(this, name);\n EnvProxy.setAttribute(this, name, newValue);\n newValue = EnvProxy.getAttribute(this, name);\n internals.attributeChangedCallback(this, name, oldValue, newValue, null);\n });\n\n Utilities.setPropertyUnchecked(Element.prototype, 'setAttributeNS',\n /**\n * @this {Element}\n * @param {?string} namespace\n * @param {string} name\n * @param {string} newValue\n */\n function(namespace, name, newValue) {\n // Fast path for non-custom elements.\n if (this.__CE_state !== CEState.custom) {\n return EnvProxy.setAttributeNS(this, namespace, name, newValue);\n }\n\n const oldValue = EnvProxy.getAttributeNS(this, namespace, name);\n EnvProxy.setAttributeNS(this, namespace, name, newValue);\n newValue = EnvProxy.getAttributeNS(this, namespace, name);\n internals.attributeChangedCallback(this, name, oldValue, newValue, namespace);\n });\n\n Utilities.setPropertyUnchecked(Element.prototype, 'removeAttribute',\n /**\n * @this {Element}\n * @param {string} name\n */\n function(name) {\n // Fast path for non-custom elements.\n if (this.__CE_state !== CEState.custom) {\n return EnvProxy.removeAttribute(this, name);\n }\n\n const oldValue = EnvProxy.getAttribute(this, name);\n EnvProxy.removeAttribute(this, name);\n if (oldValue !== null) {\n internals.attributeChangedCallback(this, name, oldValue, null, null);\n }\n });\n\n Utilities.setPropertyUnchecked(Element.prototype, 'removeAttributeNS',\n /**\n * @this {Element}\n * @param {?string} namespace\n * @param {string} name\n */\n function(namespace, name) {\n // Fast path for non-custom elements.\n if (this.__CE_state !== CEState.custom) {\n return EnvProxy.removeAttributeNS(this, namespace, name);\n }\n\n const oldValue = EnvProxy.getAttributeNS(this, namespace, name);\n EnvProxy.removeAttributeNS(this, namespace, name);\n // In older browsers, `Element#getAttributeNS` may return the empty string\n // instead of null if the attribute does not exist. For details, see;\n // https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttributeNS#Notes\n const newValue = EnvProxy.getAttributeNS(this, namespace, name);\n if (oldValue !== newValue) {\n internals.attributeChangedCallback(this, name, oldValue, newValue, namespace);\n }\n });\n\n\n function patch_insertAdjacentElement(destination, baseMethod) {\n Utilities.setPropertyUnchecked(destination, 'insertAdjacentElement',\n /**\n * @this {Element}\n * @param {string} where\n * @param {!Element} element\n * @return {?Element}\n */\n function(where, element) {\n const wasConnected = Utilities.isConnected(element);\n const insertedElement = /** @type {!Element} */\n (baseMethod.call(this, where, element));\n\n if (wasConnected) {\n internals.disconnectTree(element);\n }\n\n if (Utilities.isConnected(insertedElement)) {\n internals.connectTree(element);\n }\n return insertedElement;\n });\n }\n\n if (Env.HTMLElement.insertAdjacentElement && Env.HTMLElement.insertAdjacentElement.value) {\n patch_insertAdjacentElement(HTMLElement.prototype, Env.HTMLElement.insertAdjacentElement.value);\n } else if (Env.Element.insertAdjacentElement && Env.Element.insertAdjacentElement.value) {\n patch_insertAdjacentElement(Element.prototype, Env.Element.insertAdjacentElement.value);\n } else {\n console.warn('Custom Elements: `Element#insertAdjacentElement` was not patched.');\n }\n\n\n PatchParentNode(internals, Element.prototype, {\n prepend: (Env.Element.prepend || {}).value,\n append: (Env.Element.append || {}).value,\n });\n\n PatchChildNode(internals, Element.prototype, {\n before: (Env.Element.before || {}).value,\n after: (Env.Element.after || {}).value,\n replaceWith: (Env.Element.replaceWith || {}).value,\n remove: (Env.Element.remove || {}).value,\n });\n};\n"]} \ No newline at end of file From f94e4f4911c0ba3ba1d18ffdbaaf097ee762f774 Mon Sep 17 00:00:00 2001 From: Russell Bicknell Date: Wed, 14 Jun 2017 16:13:59 -0700 Subject: [PATCH 13/92] Capture `HTMLElement#innerHTML` for IE. --- src/Environment.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Environment.js b/src/Environment.js index 97033f2..25998a0 100644 --- a/src/Environment.js +++ b/src/Environment.js @@ -47,6 +47,7 @@ export const HTMLElement = { proto: envHTMLElement_proto, innerHTML: getDescriptor(envHTMLElement_proto, 'innerHTML'), + insertAdjacentElement: getDescriptor(envHTMLElement_proto, 'insertAdjacentElement'), }; const envHTMLTemplateElement = window['HTMLTemplateElement']; From 757ea93a54e30ef424955dccc0dacd7888ed195c Mon Sep 17 00:00:00 2001 From: Russell Bicknell Date: Wed, 14 Jun 2017 16:23:22 -0700 Subject: [PATCH 14/92] Only attempt to access properties of HTMLTemplateElement if it exists. --- src/Environment.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Environment.js b/src/Environment.js index 25998a0..040e8fd 100644 --- a/src/Environment.js +++ b/src/Environment.js @@ -50,14 +50,14 @@ export const HTMLElement = { insertAdjacentElement: getDescriptor(envHTMLElement_proto, 'insertAdjacentElement'), }; +export const HTMLTemplateElement = {}; const envHTMLTemplateElement = window['HTMLTemplateElement']; -const envHTMLTemplateElement_proto = envHTMLTemplateElement['prototype']; -export const HTMLTemplateElement = { - self: envHTMLTemplateElement, - proto: envHTMLTemplateElement_proto, - - content: getDescriptor(envHTMLTemplateElement_proto, 'content'), -}; +if (envHTMLTemplateElement) { + const envHTMLTemplateElement_proto = envHTMLTemplateElement['prototype']; + HTMLTemplateElement.self = envHTMLTemplateElement; + HTMLTemplateElement.proto = envHTMLTemplateElement_proto; + HTMLTemplateElement.content = getDescriptor(envHTMLTemplateElement_proto, 'content'); +} const envMutationObserver = window['MutationObserver']; const envMutationObserver_proto = envMutationObserver['prototype']; From 9c844c9ac67417fa667a2fa92e6b2e5f0b360cd6 Mon Sep 17 00:00:00 2001 From: Russell Bicknell Date: Wed, 14 Jun 2017 16:29:38 -0700 Subject: [PATCH 15/92] Remove use of a