From f40a213b7e26b5d9499856c4e3f0dcb94770c3fb Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Mon, 24 Apr 2017 14:11:53 -0700 Subject: [PATCH 1/2] Fixes #139. In add/removeEventListener patches, default to `window` if there is no `this`. --- shadydom.min.js | 46 +++++++++++++++++++++---------------------- shadydom.min.js.map | 2 +- src/patch-events.js | 28 +++++++++++++++----------- tests/event-path.html | 14 +++++++++++++ 4 files changed, 54 insertions(+), 36 deletions(-) diff --git a/shadydom.min.js b/shadydom.min.js index dceb448..5d60e29 100644 --- a/shadydom.min.js +++ b/shadydom.min.js @@ -9,12 +9,12 @@ Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ 'use strict';function n(a,b){return{index:a,l:[],o:b}} -function aa(a,b,c,d){var e=0,h=0,g=0,f=0,k=Math.min(b-e,d-h);if(0==e&&0==h)a:{for(g=0;g]/g;function ja(a){switch(a){case "&":return"&";case "<":return"<";case ">":return">";case '"':return""";case "\u00a0":return" "}}function ka(a){for(var b={},c=0;c";break a;case Node.TEXT_NODE:f=f.data;f=k&&ma[k.localName]?f:f.replace(ia,ja);break a;case Node.COMMENT_NODE:f="\x3c!--"+f.data+"--\x3e";break a;default:throw window.console.error(f), +function H(a,b){"template"===a.localName&&(a=a.content);for(var c="",d=b?b(a):a.childNodes,e=0,k=d.length,g;e";break a;case Node.TEXT_NODE:f=f.data;f=h&&ma[h.localName]?f:f.replace(ia,ja);break a;case Node.COMMENT_NODE:f="\x3c!--"+f.data+"--\x3e";break a;default:throw window.console.error(f), Error("not implemented");}}c+=f}return c};var I={},J=document.createTreeWalker(document,NodeFilter.SHOW_ALL,null,!1),K=document.createTreeWalker(document,NodeFilter.SHOW_ELEMENT,null,!1);function na(a){var b=[];J.currentNode=a;for(a=J.firstChild();a;)b.push(a),a=J.nextSibling();return b}I.parentNode=function(a){J.currentNode=a;return J.parentNode()};I.firstChild=function(a){J.currentNode=a;return J.firstChild()};I.lastChild=function(a){J.currentNode=a;return J.lastChild()};I.previousSibling=function(a){J.currentNode=a;return J.previousSibling()}; I.nextSibling=function(a){J.currentNode=a;return J.nextSibling()};I.childNodes=na;I.parentElement=function(a){K.currentNode=a;return K.parentNode()};I.firstElementChild=function(a){K.currentNode=a;return K.firstChild()};I.lastElementChild=function(a){K.currentNode=a;return K.lastChild()};I.previousElementSibling=function(a){K.currentNode=a;return K.previousSibling()};I.nextElementSibling=function(a){K.currentNode=a;return K.nextSibling()}; I.children=function(a){var b=[];K.currentNode=a;for(a=K.firstChild();a;)b.push(a),a=K.nextSibling();return b};I.innerHTML=function(a){return H(a,function(a){return na(a)})};I.textContent=function(a){if(a.nodeType!==Node.ELEMENT_NODE)return a.nodeValue;a=document.createTreeWalker(a,NodeFilter.SHOW_TEXT,null,!1);for(var b="",c;c=a.nextNode();)b+=c.nodeValue;return b};var M=Object.getOwnPropertyDescriptor(Element.prototype,"innerHTML")||Object.getOwnPropertyDescriptor(HTMLElement.prototype,"innerHTML"),N=document.implementation.createHTMLDocument("inert").createElement("div"),O=Object.getOwnPropertyDescriptor(Document.prototype,"activeElement"),oa={parentElement:{get:function(){var a=this.__shady&&this.__shady.parentNode;a&&a.nodeType!==Node.ELEMENT_NODE&&(a=null);return void 0!==a?a:I.parentElement(this)},configurable:!0},parentNode:{get:function(){var a=this.__shady&& @@ -28,39 +28,39 @@ this.__shady.root||null},set:function(a){this.__shady=this.__shady||{};this.__sh function R(a,b,c){for(var d in b){var e=Object.getOwnPropertyDescriptor(a,d);e&&e.configurable||!e&&c?Object.defineProperty(a,d,b[d]):c&&console.warn("Could not define",d,"on",a)}}function S(a){R(a,oa);R(a,P);R(a,Q)}var qa=p.i?function(){}:function(a){a.__shady&&a.__shady.O||(a.__shady=a.__shady||{},a.__shady.O=!0,R(a,oa,!0))},ra=p.i?function(){}:function(a){a.__shady&&a.__shady.M||(a.__shady=a.__shady||{},a.__shady.M=!0,R(a,P,!0),R(a,pa,!0))};function sa(a,b,c){qa(a);c=c||null;a.__shady=a.__shady||{};b.__shady=b.__shady||{};c&&(c.__shady=c.__shady||{});a.__shady.previousSibling=c?c.__shady.previousSibling:b.lastChild;var d=a.__shady.previousSibling;d&&d.__shady&&(d.__shady.nextSibling=a);(d=a.__shady.nextSibling=c)&&d.__shady&&(d.__shady.previousSibling=a);a.__shady.parentNode=b;c?c===b.__shady.firstChild&&(b.__shady.firstChild=a):(b.__shady.lastChild=a,b.__shady.firstChild||(b.__shady.firstChild=a));b.__shady.childNodes=null} function T(a){if(!a.__shady||void 0===a.__shady.firstChild){a.__shady=a.__shady||{};a.__shady.firstChild=I.firstChild(a);a.__shady.lastChild=I.lastChild(a);ra(a);for(var b=a.__shady.childNodes=I.childNodes(a),c=0,d;c '123yyyy'\n//\n// With 1-edit updates, the shortest path would be just to update all seven\n// characters. With 2-edit updates, we delete 4, leave 3, and add 4. This\n// leaves the substring '123' intact.\nfunction calcEditDistances(current, currentStart, currentEnd,\n old, oldStart, oldEnd) {\n // \"Deletion\" columns\n let rowCount = oldEnd - oldStart + 1;\n let columnCount = currentEnd - currentStart + 1;\n let distances = new Array(rowCount);\n\n // \"Addition\" rows. Initialize null column.\n for (let i = 0; i < rowCount; i++) {\n distances[i] = new Array(columnCount);\n distances[i][0] = i;\n }\n\n // Initialize null row\n for (let j = 0; j < columnCount; j++)\n distances[0][j] = j;\n\n for (let i = 1; i < rowCount; i++) {\n for (let j = 1; j < columnCount; j++) {\n if (equals(current[currentStart + j - 1], old[oldStart + i - 1]))\n distances[i][j] = distances[i - 1][j - 1];\n else {\n let north = distances[i - 1][j] + 1;\n let west = distances[i][j - 1] + 1;\n distances[i][j] = north < west ? north : west;\n }\n }\n }\n\n return distances;\n}\n\n// This starts at the final weight, and walks \"backward\" by finding\n// the minimum previous weight recursively until the origin of the weight\n// matrix.\nfunction spliceOperationsFromEditDistances(distances) {\n let i = distances.length - 1;\n let j = distances[0].length - 1;\n let current = distances[i][j];\n let edits = [];\n while (i > 0 || j > 0) {\n if (i == 0) {\n edits.push(EDIT_ADD);\n j--;\n continue;\n }\n if (j == 0) {\n edits.push(EDIT_DELETE);\n i--;\n continue;\n }\n let northWest = distances[i - 1][j - 1];\n let west = distances[i - 1][j];\n let north = distances[i][j - 1];\n\n let min;\n if (west < north)\n min = west < northWest ? west : northWest;\n else\n min = north < northWest ? north : northWest;\n\n if (min == northWest) {\n if (northWest == current) {\n edits.push(EDIT_LEAVE);\n } else {\n edits.push(EDIT_UPDATE);\n current = northWest;\n }\n i--;\n j--;\n } else if (min == west) {\n edits.push(EDIT_DELETE);\n i--;\n current = west;\n } else {\n edits.push(EDIT_ADD);\n j--;\n current = north;\n }\n }\n\n edits.reverse();\n return edits;\n}\n\n/**\n * Splice Projection functions:\n *\n * A splice map is a representation of how a previous array of items\n * was transformed into a new array of items. Conceptually it is a list of\n * tuples of\n *\n * \n *\n * which are kept in ascending index order of. The tuple represents that at\n * the |index|, |removed| sequence of items were removed, and counting forward\n * from |index|, |addedCount| items were added.\n */\n\n/**\n * Lacking individual splice mutation information, the minimal set of\n * splices can be synthesized given the previous state and final state of an\n * array. The basic approach is to calculate the edit distance matrix and\n * choose the shortest path through it.\n *\n * Complexity: O(l * p)\n * l: The length of the current array\n * p: The length of the old array\n */\nfunction calcSplices(current, currentStart, currentEnd,\n old, oldStart, oldEnd) {\n let prefixCount = 0;\n let suffixCount = 0;\n let splice;\n\n let minLength = Math.min(currentEnd - currentStart, oldEnd - oldStart);\n if (currentStart == 0 && oldStart == 0)\n prefixCount = sharedPrefix(current, old, minLength);\n\n if (currentEnd == current.length && oldEnd == old.length)\n suffixCount = sharedSuffix(current, old, minLength - prefixCount);\n\n currentStart += prefixCount;\n oldStart += prefixCount;\n currentEnd -= suffixCount;\n oldEnd -= suffixCount;\n\n if (currentEnd - currentStart == 0 && oldEnd - oldStart == 0)\n return [];\n\n if (currentStart == currentEnd) {\n splice = newSplice(currentStart, [], 0);\n while (oldStart < oldEnd)\n splice.removed.push(old[oldStart++]);\n\n return [ splice ];\n } else if (oldStart == oldEnd)\n return [ newSplice(currentStart, [], currentEnd - currentStart) ];\n\n let ops = spliceOperationsFromEditDistances(\n calcEditDistances(current, currentStart, currentEnd,\n old, oldStart, oldEnd));\n\n splice = undefined;\n let splices = [];\n let index = currentStart;\n let oldIndex = oldStart;\n for (let i = 0; i < ops.length; i++) {\n switch(ops[i]) {\n case EDIT_LEAVE:\n if (splice) {\n splices.push(splice);\n splice = undefined;\n }\n\n index++;\n oldIndex++;\n break;\n case EDIT_UPDATE:\n if (!splice)\n splice = newSplice(index, [], 0);\n\n splice.addedCount++;\n index++;\n\n splice.removed.push(old[oldIndex]);\n oldIndex++;\n break;\n case EDIT_ADD:\n if (!splice)\n splice = newSplice(index, [], 0);\n\n splice.addedCount++;\n index++;\n break;\n case EDIT_DELETE:\n if (!splice)\n splice = newSplice(index, [], 0);\n\n splice.removed.push(old[oldIndex]);\n oldIndex++;\n break;\n }\n }\n\n if (splice) {\n splices.push(splice);\n }\n return splices;\n}\n\nfunction sharedPrefix(current, old, searchLength) {\n for (let i = 0; i < searchLength; i++)\n if (!equals(current[i], old[i]))\n return i;\n return searchLength;\n}\n\nfunction sharedSuffix(current, old, searchLength) {\n let index1 = current.length;\n let index2 = old.length;\n let count = 0;\n while (count < searchLength && equals(current[--index1], old[--index2]))\n count++;\n\n return count;\n}\n\nfunction equals(currentValue, previousValue) {\n return currentValue === previousValue;\n}\n\nexport function calculateSplices(current, previous) {\n return calcSplices(current, 0, current.length, previous, 0,\n previous.length);\n}\n\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nexport let settings = window['ShadyDOM'] || {};\n\nsettings.hasNativeShadowDOM = Boolean(Element.prototype.attachShadow && Node.prototype.getRootNode);\n\nlet desc = Object.getOwnPropertyDescriptor(Node.prototype, 'firstChild');\n\nsettings.hasDescriptors = Boolean(desc && desc.configurable && desc.get);\nsettings.inUse = settings['force'] || !settings.hasNativeShadowDOM;\n\nexport function isShadyRoot(obj) {\n return Boolean(obj.__localName === 'ShadyRoot');\n}\n\nexport function ownerShadyRootForNode(node) {\n let root = node.getRootNode();\n if (isShadyRoot(root)) {\n return root;\n }\n}\n\nlet p = Element.prototype;\nlet matches = p.matches || p.matchesSelector ||\n p.mozMatchesSelector || p.msMatchesSelector ||\n p.oMatchesSelector || p.webkitMatchesSelector;\n\nexport function matchesSelector(element, selector) {\n return matches.call(element, selector);\n}\n\nfunction copyOwnProperty(name, source, target) {\n let pd = Object.getOwnPropertyDescriptor(source, name);\n if (pd) {\n Object.defineProperty(target, name, pd);\n }\n}\n\nexport function extend(target, source) {\n if (target && source) {\n let n$ = Object.getOwnPropertyNames(source);\n for (let i=0, n; (i {\n while (queue.length) {\n // catch errors in user code...\n try {\n queue.shift()();\n } catch(e) {\n // enqueue another record and throw\n twiddle.textContent = content++;\n throw(e);\n }\n }\n}).observe(twiddle, {characterData: true});\n\n// use MutationObserver to get microtask async timing.\nexport function microtask(callback) {\n queue.push(callback);\n twiddle.textContent = content++;\n}","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport * as utils from './utils'\n\n// render enqueuer/flusher\nlet flushList = [];\nlet scheduled;\nexport function enqueue(callback) {\n if (!scheduled) {\n scheduled = true;\n utils.microtask(flush);\n }\n flushList.push(callback);\n}\n\nexport function flush() {\n scheduled = false;\n let didFlush = Boolean(flushList.length);\n while (flushList.length) {\n flushList.shift()();\n }\n return didFlush;\n}\n\nflush['list'] = flushList;","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\n// Cribbed from ShadowDOM polyfill\n// https://github.com/webcomponents/webcomponentsjs/blob/master/src/ShadowDOM/wrappers/HTMLElement.js#L28\n/////////////////////////////////////////////////////////////////////////////\n// innerHTML and outerHTML\n\n// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#escapingString\nlet escapeAttrRegExp = /[&\\u00A0\"]/g;\nlet escapeDataRegExp = /[&\\u00A0<>]/g;\n\nfunction escapeReplace(c) {\n switch (c) {\n case '&':\n return '&';\n case '<':\n return '<';\n case '>':\n return '>';\n case '\"':\n return '"';\n case '\\u00A0':\n return ' ';\n }\n}\n\nfunction escapeAttr(s) {\n return s.replace(escapeAttrRegExp, escapeReplace);\n}\n\nfunction escapeData(s) {\n return s.replace(escapeDataRegExp, escapeReplace);\n}\n\nfunction makeSet(arr) {\n let set = {};\n for (let i = 0; i < arr.length; i++) {\n set[arr[i]] = true;\n }\n return set;\n}\n\n// http://www.whatwg.org/specs/web-apps/current-work/#void-elements\nlet voidElements = makeSet([\n 'area',\n 'base',\n 'br',\n 'col',\n 'command',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'keygen',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr'\n]);\n\nlet plaintextParents = makeSet([\n 'style',\n 'script',\n 'xmp',\n 'iframe',\n 'noembed',\n 'noframes',\n 'plaintext',\n 'noscript'\n]);\n\n/**\n * @param {Node} node\n * @param {Node} parentNode\n * @param {Function=} callback\n */\nexport function getOuterHTML(node, parentNode, callback) {\n switch (node.nodeType) {\n case Node.ELEMENT_NODE: {\n let tagName = node.localName;\n let s = '<' + tagName;\n let attrs = node.attributes;\n for (let i = 0, attr; (attr = attrs[i]); i++) {\n s += ' ' + attr.name + '=\"' + escapeAttr(attr.value) + '\"';\n }\n s += '>';\n if (voidElements[tagName]) {\n return s;\n }\n return s + getInnerHTML(node, callback) + '';\n }\n case Node.TEXT_NODE: {\n let data = /** @type {Text} */ (node).data;\n if (parentNode && plaintextParents[parentNode.localName]) {\n return data;\n }\n return escapeData(data);\n }\n case Node.COMMENT_NODE: {\n return '';\n }\n default: {\n window.console.error(node);\n throw new Error('not implemented');\n }\n }\n}\n\n/**\n * @param {Node} node\n * @param {Function=} callback\n */\nexport function getInnerHTML(node, callback) {\n if (node.localName === 'template') {\n node = /** @type {HTMLTemplateElement} */ (node).content;\n }\n let s = '';\n let c$ = callback ? callback(node) : node.childNodes;\n for (let i=0, l=c$.length, child; (i childNodes(n));\n}\n\nexport function textContent(node) {\n if (node.nodeType !== Node.ELEMENT_NODE) {\n return node.nodeValue;\n }\n let textWalker = document.createTreeWalker(node, NodeFilter.SHOW_TEXT,\n null, false);\n let content = '', n;\n while ( (n = textWalker.nextNode()) ) {\n // TODO(sorvell): can't use textContent since we patch it on Node.prototype!\n // However, should probably patch it only on element.\n content += n.nodeValue;\n }\n return content;\n}","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport * as utils from './utils'\nimport {getInnerHTML} from './innerHTML'\nimport * as nativeTree from './native-tree'\n\nfunction clearNode(node) {\n while (node.firstChild) {\n node.removeChild(node.firstChild);\n }\n}\n\nconst nativeInnerHTMLDesc = /** @type {ObjectPropertyDescriptor} */(\n Object.getOwnPropertyDescriptor(Element.prototype, 'innerHTML') ||\n Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'innerHTML'));\n\nconst inertDoc = document.implementation.createHTMLDocument('inert');\nconst htmlContainer = inertDoc.createElement('div');\n\nconst nativeActiveElementDescriptor =\n /** @type {ObjectPropertyDescriptor} */(\n Object.getOwnPropertyDescriptor(Document.prototype, 'activeElement')\n );\nfunction getDocumentActiveElement() {\n if (nativeActiveElementDescriptor && nativeActiveElementDescriptor.get) {\n return nativeActiveElementDescriptor.get.call(document);\n } else if (!utils.settings.hasDescriptors) {\n return document.activeElement;\n }\n}\n\nfunction activeElementForNode(node) {\n let active = getDocumentActiveElement();\n // In IE11, activeElement might be an empty object if the document is\n // contained in an iframe.\n // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10998788/\n if (!active || !active.nodeType) {\n return null;\n }\n let isShadyRoot = !!(utils.isShadyRoot(node));\n if (node !== document) {\n // If this node isn't a document or shady root, then it doesn't have\n // an active element.\n if (!isShadyRoot) {\n return null;\n }\n // If this shady root's host is the active element or the active\n // element is not a descendant of the host (in the composed tree),\n // then it doesn't have an active element.\n if (node.host === active ||\n !node.host.contains(active)) {\n return null;\n }\n }\n // This node is either the document or a shady root of which the active\n // element is a (composed) descendant of its host; iterate upwards to\n // find the active element's most shallow host within it.\n let activeRoot = utils.ownerShadyRootForNode(active);\n while (activeRoot && activeRoot !== node) {\n active = activeRoot.host;\n activeRoot = utils.ownerShadyRootForNode(active);\n }\n if (node === document) {\n // This node is the document, so activeRoot should be null.\n return activeRoot ? null : active;\n } else {\n // This node is a non-document shady root, and it should be\n // activeRoot.\n return activeRoot === node ? active : null;\n }\n}\n\nlet OutsideAccessors = {\n\n parentElement: {\n /** @this {Node} */\n get() {\n let l = this.__shady && this.__shady.parentNode;\n if (l && l.nodeType !== Node.ELEMENT_NODE) {\n l = null;\n }\n return l !== undefined ? l : nativeTree.parentElement(this);\n },\n configurable: true\n },\n\n parentNode: {\n /** @this {Node} */\n get() {\n let l = this.__shady && this.__shady.parentNode;\n return l !== undefined ? l : nativeTree.parentNode(this);\n },\n configurable: true\n },\n\n nextSibling: {\n /** @this {Node} */\n get() {\n let l = this.__shady && this.__shady.nextSibling;\n return l !== undefined ? l : nativeTree.nextSibling(this);\n },\n configurable: true\n },\n\n previousSibling: {\n /** @this {Node} */\n get() {\n let l = this.__shady && this.__shady.previousSibling;\n return l !== undefined ? l : nativeTree.previousSibling(this);\n },\n configurable: true\n },\n\n className: {\n /**\n * @this {HTMLElement}\n */\n get() {\n return this.getAttribute('class') || '';\n },\n /**\n * @this {HTMLElement}\n */\n set(value) {\n this.setAttribute('class', value);\n },\n configurable: true\n },\n\n // fragment, element, document\n nextElementSibling: {\n /**\n * @this {HTMLElement}\n */\n get() {\n if (this.__shady && this.__shady.nextSibling !== undefined) {\n let n = this.nextSibling;\n while (n && n.nodeType !== Node.ELEMENT_NODE) {\n n = n.nextSibling;\n }\n return n;\n } else {\n return nativeTree.nextElementSibling(this);\n }\n },\n configurable: true\n },\n\n previousElementSibling: {\n /**\n * @this {HTMLElement}\n */\n get() {\n if (this.__shady && this.__shady.previousSibling !== undefined) {\n let n = this.previousSibling;\n while (n && n.nodeType !== Node.ELEMENT_NODE) {\n n = n.previousSibling;\n }\n return n;\n } else {\n return nativeTree.previousElementSibling(this);\n }\n },\n configurable: true\n }\n\n};\n\nlet InsideAccessors = {\n\n childNodes: {\n /**\n * @this {HTMLElement}\n */\n get() {\n let childNodes;\n if (this.__shady && this.__shady.firstChild !== undefined) {\n if (!this.__shady.childNodes) {\n this.__shady.childNodes = [];\n for (let n=this.firstChild; n; n=n.nextSibling) {\n this.__shady.childNodes.push(n);\n }\n }\n childNodes = this.__shady.childNodes;\n } else {\n childNodes = nativeTree.childNodes(this);\n }\n childNodes.item = function(index) {\n return childNodes[index];\n }\n return childNodes;\n },\n configurable: true\n },\n\n childElementCount: {\n /** @this {HTMLElement} */\n get() {\n return this.children.length;\n },\n configurable: true\n },\n\n firstChild: {\n /** @this {HTMLElement} */\n get() {\n let l = this.__shady && this.__shady.firstChild;\n return l !== undefined ? l : nativeTree.firstChild(this);\n },\n configurable: true\n },\n\n lastChild: {\n /** @this {HTMLElement} */\n get() {\n let l = this.__shady && this.__shady.lastChild;\n return l !== undefined ? l : nativeTree.lastChild(this);\n },\n configurable: true\n },\n\n textContent: {\n /**\n * @this {HTMLElement}\n */\n get() {\n if (this.__shady && this.__shady.firstChild !== undefined) {\n let tc = [];\n for (let i = 0, cn = this.childNodes, c; (c = cn[i]); i++) {\n if (c.nodeType !== Node.COMMENT_NODE) {\n tc.push(c.textContent);\n }\n }\n return tc.join('');\n } else {\n return nativeTree.textContent(this);\n }\n },\n /**\n * @this {HTMLElement}\n */\n set(text) {\n if (this.nodeType !== Node.ELEMENT_NODE) {\n // TODO(sorvell): can't do this if patch nodeValue.\n this.nodeValue = text;\n } else {\n clearNode(this);\n this.appendChild(document.createTextNode(text));\n }\n },\n configurable: true\n },\n\n // fragment, element, document\n firstElementChild: {\n /**\n * @this {HTMLElement}\n */\n get() {\n if (this.__shady && this.__shady.firstChild !== undefined) {\n let n = this.firstChild;\n while (n && n.nodeType !== Node.ELEMENT_NODE) {\n n = n.nextSibling;\n }\n return n;\n } else {\n return nativeTree.firstElementChild(this);\n }\n },\n configurable: true\n },\n\n lastElementChild: {\n /**\n * @this {HTMLElement}\n */\n get() {\n if (this.__shady && this.__shady.lastChild !== undefined) {\n let n = this.lastChild;\n while (n && n.nodeType !== Node.ELEMENT_NODE) {\n n = n.previousSibling;\n }\n return n;\n } else {\n return nativeTree.lastElementChild(this);\n }\n },\n configurable: true\n },\n\n children: {\n /**\n * @this {HTMLElement}\n */\n get() {\n let children;\n if (this.__shady && this.__shady.firstChild !== undefined) {\n children = Array.prototype.filter.call(this.childNodes, function(n) {\n return (n.nodeType === Node.ELEMENT_NODE);\n });\n } else {\n children = nativeTree.children(this);\n }\n children.item = function(index) {\n return children[index];\n }\n return children;\n },\n configurable: true\n },\n\n // element (HTMLElement on IE11)\n innerHTML: {\n /**\n * @this {HTMLElement}\n */\n get() {\n let content = this.localName === 'template' ?\n /** @type {HTMLTemplateElement} */(this).content : this;\n if (this.__shady && this.__shady.firstChild !== undefined) {\n return getInnerHTML(content);\n } else {\n return nativeTree.innerHTML(content);\n }\n },\n /**\n * @this {HTMLElement}\n */\n set(text) {\n let content = this.localName === 'template' ?\n /** @type {HTMLTemplateElement} */(this).content : this;\n clearNode(content);\n if (nativeInnerHTMLDesc && nativeInnerHTMLDesc.set) {\n nativeInnerHTMLDesc.set.call(htmlContainer, text);\n } else {\n htmlContainer.innerHTML = text;\n }\n while (htmlContainer.firstChild) {\n content.appendChild(htmlContainer.firstChild);\n }\n },\n configurable: true\n }\n\n};\n\n// Note: Can be patched on element prototype on all browsers.\n// Must be patched on instance on browsers that support native Shadow DOM\n// but do not have builtin accessors (old Chrome).\nexport let ShadowRootAccessor = {\n\n shadowRoot: {\n /**\n * @this {HTMLElement}\n */\n get() {\n return this.__shady && this.__shady.root || null;\n },\n /**\n * @this {HTMLElement}\n */\n set(value) {\n this.__shady = this.__shady || {};\n this.__shady.root = value;\n },\n configurable: true\n }\n};\n\n// Note: Can be patched on document prototype on browsers with builtin accessors.\n// Must be patched separately on simulated ShadowRoot.\n// Must be patched as `_activeElement` on browsers without builtin accessors.\nexport let ActiveElementAccessor = {\n\n activeElement: {\n /**\n * @this {HTMLElement}\n */\n get() {\n return activeElementForNode(this);\n },\n /**\n * @this {HTMLElement}\n */\n set() {},\n configurable: true\n }\n\n};\n\n// patch a group of descriptors on an object only if it exists or if the `force`\n// argument is true.\n/**\n * @param {!Object} obj\n * @param {!Object} descriptors\n * @param {boolean=} force\n */\nfunction patchAccessorGroup(obj, descriptors, force) {\n for (let p in descriptors) {\n let objDesc = Object.getOwnPropertyDescriptor(obj, p);\n if ((objDesc && objDesc.configurable) ||\n (!objDesc && force)) {\n Object.defineProperty(obj, p, descriptors[p]);\n } else if (force) {\n console.warn('Could not define', p, 'on', obj);\n }\n }\n}\n\n// patch dom accessors on proto where they exist\nexport function patchAccessors(proto) {\n patchAccessorGroup(proto, OutsideAccessors);\n patchAccessorGroup(proto, InsideAccessors);\n patchAccessorGroup(proto, ActiveElementAccessor);\n}\n\n// ensure element descriptors (IE/Edge don't have em)\nexport function patchShadowRootAccessors(proto) {\n patchAccessorGroup(proto, InsideAccessors, true);\n patchAccessorGroup(proto, ActiveElementAccessor, true);\n}\n\n// ensure an element has patched \"outside\" accessors; no-op when not needed\nexport let patchOutsideElementAccessors = utils.settings.hasDescriptors ?\n function() {} : function(element) {\n if (!(element.__shady && element.__shady.__outsideAccessors)) {\n element.__shady = element.__shady || {};\n element.__shady.__outsideAccessors = true;\n patchAccessorGroup(element, OutsideAccessors, true);\n }\n }\n\n// ensure an element has patched \"inside\" accessors; no-op when not needed\nexport let patchInsideElementAccessors = utils.settings.hasDescriptors ?\n function() {} : function(element) {\n if (!(element.__shady && element.__shady.__insideAccessors)) {\n element.__shady = element.__shady || {};\n element.__shady.__insideAccessors = true;\n patchAccessorGroup(element, InsideAccessors, true);\n patchAccessorGroup(element, ShadowRootAccessor, true);\n }\n }\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport {patchInsideElementAccessors, patchOutsideElementAccessors} from './patch-accessors'\nimport {firstChild, lastChild, childNodes} from './native-tree'\n\nexport function recordInsertBefore(node, container, ref_node) {\n patchInsideElementAccessors(container);\n container.__shady = container.__shady || {};\n if (container.__shady.firstChild !== undefined) {\n container.__shady.childNodes = null;\n }\n // handle document fragments\n if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n let c$ = node.childNodes;\n for (let i=0; i < c$.length; i++) {\n linkNode(c$[i], container, ref_node);\n }\n // cleanup logical dom in doc fragment.\n node.__shady = node.__shady || {};\n let resetTo = (node.__shady.firstChild !== undefined) ? null : undefined;\n node.__shady.firstChild = node.__shady.lastChild = resetTo;\n node.__shady.childNodes = resetTo;\n } else {\n linkNode(node, container, ref_node);\n }\n}\n\nfunction linkNode(node, container, ref_node) {\n patchOutsideElementAccessors(node);\n ref_node = ref_node || null;\n node.__shady = node.__shady || {};\n container.__shady = container.__shady || {};\n if (ref_node) {\n ref_node.__shady = ref_node.__shady || {};\n }\n // update ref_node.previousSibling <-> node\n node.__shady.previousSibling = ref_node ? ref_node.__shady.previousSibling :\n container.lastChild;\n let ps = node.__shady.previousSibling;\n if (ps && ps.__shady) {\n ps.__shady.nextSibling = node;\n }\n // update node <-> ref_node\n let ns = node.__shady.nextSibling = ref_node;\n if (ns && ns.__shady) {\n ns.__shady.previousSibling = node;\n }\n // update node <-> container\n node.__shady.parentNode = container;\n if (ref_node) {\n if (ref_node === container.__shady.firstChild) {\n container.__shady.firstChild = node;\n }\n } else {\n container.__shady.lastChild = node;\n if (!container.__shady.firstChild) {\n container.__shady.firstChild = node;\n }\n }\n // remove caching of childNodes\n container.__shady.childNodes = null;\n}\n\nexport function recordRemoveChild(node, container) {\n node.__shady = node.__shady || {};\n container.__shady = container.__shady || {};\n if (node === container.__shady.firstChild) {\n container.__shady.firstChild = node.__shady.nextSibling;\n }\n if (node === container.__shady.lastChild) {\n container.__shady.lastChild = node.__shady.previousSibling;\n }\n let p = node.__shady.previousSibling;\n let n = node.__shady.nextSibling;\n if (p) {\n p.__shady = p.__shady || {};\n p.__shady.nextSibling = n;\n }\n if (n) {\n n.__shady = n.__shady || {};\n n.__shady.previousSibling = p;\n }\n // When an element is removed, logical data is no longer tracked.\n // Explicitly set `undefined` here to indicate this. This is disginguished\n // from `null` which is set if info is null.\n node.__shady.parentNode = node.__shady.previousSibling =\n node.__shady.nextSibling = undefined;\n if (container.__shady.childNodes !== undefined) {\n // remove caching of childNodes\n container.__shady.childNodes = null;\n }\n}\n\nexport let recordChildNodes = function(node) {\n if (!node.__shady || node.__shady.firstChild === undefined) {\n node.__shady = node.__shady || {};\n node.__shady.firstChild = firstChild(node);\n node.__shady.lastChild = lastChild(node);\n patchInsideElementAccessors(node);\n let c$ = node.__shady.childNodes = childNodes(node);\n for (let i=0, n; (i host\n host.shadowRoot = this;\n this.host = host;\n // state flags\n this._renderPending = false;\n this._hasRendered = false;\n this._changePending = false;\n this._distributor = new Distributor(this);\n this.update();\n}\n\n\n// async render\nShadyRoot.prototype.update = function() {\n if (!this._renderPending) {\n this._renderPending = true;\n enqueue(() => this.render());\n }\n}\n\n// returns the oldest renderPending ancestor root.\nShadyRoot.prototype._getRenderRoot = function() {\n let renderRoot = this;\n let root = this;\n while (root) {\n if (root._renderPending) {\n renderRoot = root;\n }\n root = root._rendererForHost();\n }\n return renderRoot;\n}\n\n// Returns the shadyRoot `this.host` if `this.host`\n// has children that require distribution.\nShadyRoot.prototype._rendererForHost = function() {\n let root = this.host.getRootNode();\n if (utils.isShadyRoot(root)) {\n let c$ = this.host.childNodes;\n for (let i=0, c; i < c$.length; i++) {\n c = c$[i];\n if (this._distributor.isInsertionPoint(c)) {\n return root;\n }\n }\n }\n}\n\nShadyRoot.prototype.render = function() {\n if (this._renderPending) {\n this._getRenderRoot()['_render']();\n }\n}\n\n// NOTE: avoid renaming to ease testability.\nShadyRoot.prototype['_render'] = function() {\n this._renderPending = false;\n this._changePending = false;\n if (!this._skipUpdateInsertionPoints) {\n this.updateInsertionPoints();\n } else if (!this._hasRendered) {\n this.__insertionPoints = [];\n }\n this._skipUpdateInsertionPoints = false;\n // TODO(sorvell): can add a first render optimization here\n // to use if there are no insertion points\n // 1. clear host node of composed children\n // 2. appendChild the shadowRoot itself or (more robust) its logical children\n // NOTE: this didn't seem worth it in perf testing\n // but not ready to delete this info.\n // logical\n this.distribute();\n // physical\n this.compose();\n this._hasRendered = true;\n}\n\nShadyRoot.prototype.forceRender = function() {\n this._renderPending = true;\n this.render();\n}\n\nShadyRoot.prototype.distribute = function() {\n let dirtyRoots = this._distributor.distribute();\n for (let i=0; i children but since this case is assumed to be exceedingly\n // rare, we avoid the cost and will address with some specific api\n // when the need arises. For now, the user must call\n // distributeContent(true), which updates insertion points manually\n // and forces distribution.\n let insertionPointTag = ownerRoot && ownerRoot.getInsertionPointTag() || '';\n let fragContent = (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) &&\n !node['__noInsertionPoint'] &&\n insertionPointTag && node.querySelector(insertionPointTag);\n let wrappedContent = fragContent &&\n (fragContent.parentNode.nodeType !==\n Node.DOCUMENT_FRAGMENT_NODE);\n let hasContent = fragContent || (node.localName === insertionPointTag);\n // There are 3 possible cases where a distribution may need to occur:\n // 1. being inserted (the host of the shady root where\n // content is inserted needs distribution)\n // 2. children being inserted into parent with a shady root (parent\n // needs distribution)\n // 3. container is an insertionPoint\n if (hasContent || (container.localName === insertionPointTag) || ipAdded) {\n if (ownerRoot) {\n // note, insertion point list update is handled after node\n // mutations are complete\n updateRootViaContentChange(ownerRoot);\n }\n }\n let needsDist = _nodeNeedsDistribution(container);\n if (needsDist) {\n let root = container.__shady && container.__shady.root;\n updateRootViaContentChange(root);\n }\n // Return true when distribution will fully handle the composition\n // Note that if a content was being inserted that was wrapped by a node,\n // and the parent does not need distribution, return false to allow\n // the nodes to be added directly, after which children may be\n // distributed and composed into the wrapping node(s)\n return needsDist || (hasContent && !wrappedContent);\n}\n\n/* note: parent argument is required since node may have an out\nof date parent at this point; returns true if a is being added */\nfunction _maybeAddInsertionPoint(node, parent, root) {\n let added;\n let insertionPointTag = root.getInsertionPointTag();\n if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE &&\n !node['__noInsertionPoint']) {\n let c$ = node.querySelectorAll(insertionPointTag);\n for (let i=0, n, np, na; (i (host of container needs distribution)\n/**\n * @param {Node} parent\n * @param {Node} node\n * @param {Node=} ref_node\n */\nexport function insertBefore(parent, node, ref_node) {\n if (ref_node) {\n let p = ref_node.__shady && ref_node.__shady.parentNode;\n if ((p !== undefined && p !== parent) ||\n (p === undefined && parentNode(ref_node) !== parent)) {\n throw Error(`Failed to execute 'insertBefore' on 'Node': The node ` +\n `before which the new node is to be inserted is not a child of this node.`);\n }\n }\n if (ref_node === node) {\n return node;\n }\n // remove node from its current position iff it's in a tree.\n if (node.nodeType !== Node.DOCUMENT_FRAGMENT_NODE) {\n let parent = node.__shady && node.__shady.parentNode;\n removeNodeFromParent(node, parent);\n }\n if (!addNode(parent, node, ref_node)) {\n if (ref_node) {\n // if ref_node is an insertion point replace with first distributed node\n let root = utils.ownerShadyRootForNode(ref_node);\n if (root) {\n ref_node = ref_node.localName === root.getInsertionPointTag() ?\n firstComposedNode(/** @type {!HTMLSlotElement} */(ref_node)) : ref_node;\n }\n }\n // if adding to a shadyRoot, add to host instead\n let container = utils.isShadyRoot(parent) ? /** @type {ShadowRoot} */(parent).host : parent;\n if (ref_node) {\n nativeMethods.insertBefore.call(container, node, ref_node);\n } else {\n nativeMethods.appendChild.call(container, node);\n }\n }\n _scheduleObserver(parent, node);\n return node;\n}\n\n/**\n Removes the given `node` from the element's `lightChildren`.\n This method also performs dom composition.\n*/\nexport function removeChild(parent, node) {\n if (node.parentNode !== parent) {\n throw Error('The node to be removed is not a child of this node: ' +\n node);\n }\n if (!removeNode(node)) {\n // if removing from a shadyRoot, remove form host instead\n let container = utils.isShadyRoot(parent) ?\n parent.host :\n parent;\n // not guaranteed to physically be in container; e.g.\n // undistributed nodes.\n let nativeParent = parentNode(node);\n if (container === nativeParent) {\n nativeMethods.removeChild.call(container, node);\n }\n }\n _scheduleObserver(parent, null, node);\n return node;\n}\n\nexport function cloneNode(node, deep) {\n if (node.localName == 'template') {\n return nativeMethods.cloneNode.call(node, deep);\n } else {\n let n = nativeMethods.cloneNode.call(node, false);\n if (deep) {\n let c$ = node.childNodes;\n for (let i=0, nc; i < c$.length; i++) {\n nc = c$[i].cloneNode(true);\n n.appendChild(nc);\n }\n }\n return n;\n }\n}\n\n// note: Though not technically correct, we fast path `importNode`\n// when called on a node not owned by the main document.\n// This allows, for example, elements that cannot\n// contain custom elements and are therefore not likely to contain shadowRoots\n// to cloned natively. This is a fairly significant performance win.\nexport function importNode(node, deep) {\n if (node.ownerDocument !== document) {\n return nativeMethods.importNode.call(document, node, deep);\n }\n let n = nativeMethods.importNode.call(document, node, false);\n if (deep) {\n let c$ = node.childNodes;\n for (let i=0, nc; i < c$.length; i++) {\n nc = importNode(c$[i], true);\n n.appendChild(nc);\n }\n }\n return n;\n}\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport * as utils from './utils'\n\nclass AsyncObserver {\n\n constructor() {\n this._scheduled = false;\n this.addedNodes = [];\n this.removedNodes = [];\n this.callbacks = new Set();\n }\n\n schedule() {\n if (!this._scheduled) {\n this._scheduled = true;\n utils.microtask(() => {\n this.flush();\n });\n }\n }\n\n flush() {\n if (this._scheduled) {\n this._scheduled = false;\n let mutations = this.takeRecords();\n if (mutations.length) {\n this.callbacks.forEach(function(cb) {\n cb(mutations);\n });\n }\n }\n }\n\n takeRecords() {\n if (this.addedNodes.length || this.removedNodes.length) {\n let mutations = [{\n addedNodes: this.addedNodes,\n removedNodes: this.removedNodes\n }];\n this.addedNodes = [];\n this.removedNodes = [];\n return mutations;\n }\n return [];\n }\n\n}\n\n// TODO(sorvell): consider instead polyfilling MutationObserver\n// directly so that users do not have to fork their code.\n// Supporting the entire api may be challenging: e.g. filtering out\n// removed nodes in the wrong scope and seeing non-distributing\n// subtree child mutations.\nexport let observeChildren = function(node, callback) {\n node.__shady = node.__shady || {};\n if (!node.__shady.observer) {\n node.__shady.observer = new AsyncObserver();\n }\n node.__shady.observer.callbacks.add(callback);\n let observer = node.__shady.observer;\n return {\n _callback: callback,\n _observer: observer,\n _node: node,\n takeRecords() {\n return observer.takeRecords()\n }\n };\n}\n\nexport let unobserveChildren = function(handle) {\n let observer = handle && handle._observer;\n if (observer) {\n observer.callbacks.delete(handle._callback);\n if (!observer.callbacks.size) {\n handle._node.__shady.observer = null;\n }\n }\n}\n\nexport function filterMutations(mutations, target) {\n /** @const {Node} */\n const targetRootNode = target.getRootNode();\n return mutations.map(function(mutation) {\n /** @const {boolean} */\n const mutationInScope = (targetRootNode === mutation.target.getRootNode());\n if (mutationInScope && mutation.addedNodes) {\n let nodes = Array.from(mutation.addedNodes).filter(function(n) {\n return (targetRootNode === n.getRootNode());\n });\n if (nodes.length) {\n mutation = Object.create(mutation);\n Object.defineProperty(mutation, 'addedNodes', {\n value: nodes,\n configurable: true\n });\n return mutation;\n }\n } else if (mutationInScope) {\n return mutation;\n }\n }).filter(function(m) { return m});\n}","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport * as utils from './utils'\nimport * as nativeMethods from './native-methods'\n\n// https://github.com/w3c/webcomponents/issues/513#issuecomment-224183937\nlet alwaysComposed = {\n 'blur': true,\n 'focus': true,\n 'focusin': true,\n 'focusout': true,\n 'click': true,\n 'dblclick': true,\n 'mousedown': true,\n 'mouseenter': true,\n 'mouseleave': true,\n 'mousemove': true,\n 'mouseout': true,\n 'mouseover': true,\n 'mouseup': true,\n 'wheel': true,\n 'beforeinput': true,\n 'input': true,\n 'keydown': true,\n 'keyup': true,\n 'compositionstart': true,\n 'compositionupdate': true,\n 'compositionend': true,\n 'touchstart': true,\n 'touchend': true,\n 'touchmove': true,\n 'touchcancel': true,\n 'pointerover': true,\n 'pointerenter': true,\n 'pointerdown': true,\n 'pointermove': true,\n 'pointerup': true,\n 'pointercancel': true,\n 'pointerout': true,\n 'pointerleave': true,\n 'gotpointercapture': true,\n 'lostpointercapture': true,\n 'dragstart': true,\n 'drag': true,\n 'dragenter': true,\n 'dragleave': true,\n 'dragover': true,\n 'drop': true,\n 'dragend': true,\n 'DOMActivate': true,\n 'DOMFocusIn': true,\n 'DOMFocusOut': true,\n 'keypress': true\n};\n\nfunction pathComposer(startNode, composed) {\n let composedPath = [];\n let current = startNode;\n let startRoot = startNode === window ? window : startNode.getRootNode();\n while (current) {\n composedPath.push(current);\n if (current.assignedSlot) {\n current = current.assignedSlot;\n } else if (current.nodeType === Node.DOCUMENT_FRAGMENT_NODE && current.host && (composed || current !== startRoot)) {\n current = current.host;\n } else {\n current = current.parentNode;\n }\n }\n // event composedPath includes window when startNode's ownerRoot is document\n if (composedPath[composedPath.length - 1] === document) {\n composedPath.push(window);\n }\n return composedPath;\n}\n\nfunction retarget(refNode, path) {\n if (!utils.isShadyRoot) {\n return refNode;\n }\n // If ANCESTOR's root is not a shadow root or ANCESTOR's root is BASE's\n // shadow-including inclusive ancestor, return ANCESTOR.\n let refNodePath = pathComposer(refNode, true);\n let p$ = path;\n for (let i=0, ancestor, lastRoot, root, rootIdx; i < p$.length; i++) {\n ancestor = p$[i];\n root = ancestor === window ? window : ancestor.getRootNode();\n if (root !== lastRoot) {\n rootIdx = refNodePath.indexOf(root);\n lastRoot = root;\n }\n if (!utils.isShadyRoot(root) || rootIdx > -1) {\n return ancestor;\n }\n }\n}\n\nlet eventMixin = {\n\n /**\n * @this {Event}\n */\n get composed() {\n // isTrusted may not exist in this browser, so just check if isTrusted is explicitly false\n if (this.isTrusted !== false && this.__composed === undefined) {\n this.__composed = alwaysComposed[this.type];\n }\n return this.__composed || false;\n },\n\n /**\n * @this {Event}\n */\n composedPath() {\n if (!this.__composedPath) {\n this.__composedPath = pathComposer(this['__target'], this.composed);\n }\n return this.__composedPath;\n },\n\n /**\n * @this {Event}\n */\n get target() {\n return retarget(this.currentTarget, this.composedPath());\n },\n\n // http://w3c.github.io/webcomponents/spec/shadow/#event-relatedtarget-retargeting\n /**\n * @this {Event}\n */\n get relatedTarget() {\n if (!this.__relatedTarget) {\n return null;\n }\n if (!this.__relatedTargetComposedPath) {\n this.__relatedTargetComposedPath = pathComposer(this.__relatedTarget, true);\n }\n // find the deepest node in relatedTarget composed path that is in the same root with the currentTarget\n return retarget(this.currentTarget, this.__relatedTargetComposedPath);\n },\n /**\n * @this {Event}\n */\n stopPropagation() {\n Event.prototype.stopPropagation.call(this);\n this.__propagationStopped = true;\n },\n /**\n * @this {Event}\n */\n stopImmediatePropagation() {\n Event.prototype.stopImmediatePropagation.call(this);\n this.__immediatePropagationStopped = true;\n this.__propagationStopped = true;\n }\n\n};\n\nfunction mixinComposedFlag(Base) {\n // NOTE: avoiding use of `class` here so that transpiled output does not\n // try to do `Base.call` with a dom construtor.\n let klazz = function(type, options) {\n let event = new Base(type, options);\n event.__composed = options && Boolean(options['composed']);\n return event;\n }\n // put constructor properties on subclass\n utils.mixin(klazz, Base);\n klazz.prototype = Base.prototype;\n return klazz;\n}\n\nlet nonBubblingEventsToRetarget = {\n 'focus': true,\n 'blur': true\n};\n\n\nfunction fireHandlers(event, node, phase) {\n let hs = node.__handlers && node.__handlers[event.type] &&\n node.__handlers[event.type][phase];\n if (hs) {\n for (let i = 0, fn; (fn = hs[i]); i++) {\n if (event.target === event.relatedTarget) {\n return;\n }\n fn.call(node, event);\n if (event.__immediatePropagationStopped) {\n return;\n }\n }\n }\n}\n\nfunction retargetNonBubblingEvent(e) {\n let path = e.composedPath();\n let node;\n // override `currentTarget` to let patched `target` calculate correctly\n Object.defineProperty(e, 'currentTarget', {\n get: function() {\n return node;\n },\n configurable: true\n });\n for (let i = path.length - 1; i >= 0; i--) {\n node = path[i];\n // capture phase fires all capture handlers\n fireHandlers(e, node, 'capture');\n if (e.__propagationStopped) {\n return;\n }\n }\n\n // set the event phase to `AT_TARGET` as in spec\n Object.defineProperty(e, 'eventPhase', {get() { return Event.AT_TARGET }});\n\n // the event only needs to be fired when owner roots change when iterating the event path\n // keep track of the last seen owner root\n let lastFiredRoot;\n for (let i = 0; i < path.length; i++) {\n node = path[i];\n if (i === 0 || (node.shadowRoot && node.shadowRoot === lastFiredRoot)) {\n fireHandlers(e, node, 'bubble');\n // don't bother with window, it doesn't have `getRootNode` and will be last in the path anyway\n if (node !== window) {\n lastFiredRoot = node.getRootNode();\n }\n if (e.__propagationStopped) {\n return;\n }\n }\n }\n}\n\nfunction listenerSettingsEqual(savedListener, node, type, capture, once, passive) {\n let {\n node: savedNode,\n type: savedType,\n capture: savedCapture,\n once: savedOnce,\n passive: savedPassive\n } = savedListener;\n return node === savedNode &&\n type === savedType &&\n capture === savedCapture &&\n once === savedOnce &&\n passive === savedPassive;\n}\n\nexport function findListener(wrappers, node, type, capture, once, passive) {\n for (let i = 0; i < wrappers.length; i++) {\n if (listenerSettingsEqual(wrappers[i], node, type, capture, once, passive)) {\n return i;\n }\n }\n return -1;\n}\n\n/**\n * @this {Event}\n */\nexport function addEventListener(type, fnOrObj, optionsOrCapture) {\n if (!fnOrObj) {\n return;\n }\n\n // The callback `fn` might be used for multiple nodes/events. Since we generate\n // a wrapper function, we need to keep track of it when we remove the listener.\n // It's more efficient to store the node/type/options information as Array in\n // `fn` itself rather than the node (we assume that the same callback is used\n // for few nodes at most, whereas a node will likely have many event listeners).\n // NOTE(valdrin) invoking external functions is costly, inline has better perf.\n let capture, once, passive;\n if (typeof optionsOrCapture === 'object') {\n capture = Boolean(optionsOrCapture.capture);\n once = Boolean(optionsOrCapture.once);\n passive = Boolean(optionsOrCapture.passive);\n } else {\n capture = Boolean(optionsOrCapture);\n once = false;\n passive = false;\n }\n // hack to let ShadyRoots have event listeners\n // event listener will be on host, but `currentTarget`\n // will be set to shadyroot for event listener\n let target = optionsOrCapture && optionsOrCapture.__shadyTarget || this;\n\n if (fnOrObj.__eventWrappers) {\n // Stop if the wrapper function has already been created.\n if (findListener(fnOrObj.__eventWrappers, target, type, capture, once, passive) > -1) {\n return;\n }\n } else {\n fnOrObj.__eventWrappers = [];\n }\n\n /**\n * @this {HTMLElement}\n */\n const wrapperFn = function(e) {\n // Support `once` option.\n if (once) {\n this.removeEventListener(type, fnOrObj, optionsOrCapture);\n }\n if (!e['__target']) {\n patchEvent(e);\n }\n let lastCurrentTargetDesc;\n if (target !== this) {\n // replace `currentTarget` to make `target` and `relatedTarget` correct for inside the shadowroot\n lastCurrentTargetDesc = Object.getOwnPropertyDescriptor(e, 'currentTarget');\n Object.defineProperty(e, 'currentTarget', {get() { return target }, configurable: true});\n }\n // There are two critera that should stop events from firing on this node\n // 1. the event is not composed and the current node is not in the same root as the target\n // 2. when bubbling, if after retargeting, relatedTarget and target point to the same node\n if (e.composed || e.composedPath().indexOf(target) > -1) {\n if (e.target === e.relatedTarget) {\n if (e.eventPhase === Event.BUBBLING_PHASE) {\n e.stopImmediatePropagation();\n }\n return;\n }\n // prevent non-bubbling events from triggering bubbling handlers on shadowroot, but only if not in capture phase\n if (e.eventPhase !== Event.CAPTURING_PHASE && !e.bubbles && e.target !== target) {\n return;\n }\n let ret = (typeof fnOrObj === 'object' && fnOrObj.handleEvent) ?\n fnOrObj.handleEvent(e) :\n fnOrObj.call(target, e);\n if (target !== this) {\n // replace the \"correct\" `currentTarget`\n if (lastCurrentTargetDesc) {\n Object.defineProperty(e, 'currentTarget', lastCurrentTargetDesc);\n lastCurrentTargetDesc = null;\n } else {\n delete e['currentTarget'];\n }\n }\n return ret;\n }\n };\n // Store the wrapper information.\n fnOrObj.__eventWrappers.push({\n node: this,\n type: type,\n capture: capture,\n once: once,\n passive: passive,\n wrapperFn: wrapperFn\n });\n\n if (nonBubblingEventsToRetarget[type]) {\n this.__handlers = this.__handlers || {};\n this.__handlers[type] = this.__handlers[type] ||\n {'capture': [], 'bubble': []};\n this.__handlers[type][capture ? 'capture' : 'bubble'].push(wrapperFn);\n } else {\n let ael = this instanceof Window ? nativeMethods.windowAddEventListener :\n nativeMethods.addEventListener;\n ael.call(this, type, wrapperFn, optionsOrCapture);\n }\n}\n\n/**\n * @this {Event}\n */\nexport function removeEventListener(type, fnOrObj, optionsOrCapture) {\n if (!fnOrObj) {\n return;\n }\n\n // NOTE(valdrin) invoking external functions is costly, inline has better perf.\n let capture, once, passive;\n if (typeof optionsOrCapture === 'object') {\n capture = Boolean(optionsOrCapture.capture);\n once = Boolean(optionsOrCapture.once);\n passive = Boolean(optionsOrCapture.passive);\n } else {\n capture = Boolean(optionsOrCapture);\n once = false;\n passive = false;\n }\n let target = optionsOrCapture && optionsOrCapture.__shadyTarget || this;\n // Search the wrapped function.\n let wrapperFn = undefined;\n if (fnOrObj.__eventWrappers) {\n let idx = findListener(fnOrObj.__eventWrappers, target, type, capture, once, passive);\n if (idx > -1) {\n wrapperFn = fnOrObj.__eventWrappers.splice(idx, 1)[0].wrapperFn;\n // Cleanup.\n if (!fnOrObj.__eventWrappers.length) {\n fnOrObj.__eventWrappers = undefined;\n }\n }\n }\n let rel = this instanceof Window ? nativeMethods.windowRemoveEventListener :\n nativeMethods.removeEventListener;\n rel.call(this, type, wrapperFn || fnOrObj, optionsOrCapture);\n if (wrapperFn && nonBubblingEventsToRetarget[type] &&\n this.__handlers && this.__handlers[type]) {\n const arr = this.__handlers[type][capture ? 'capture' : 'bubble'];\n const idx = arr.indexOf(wrapperFn);\n if (idx > -1) {\n arr.splice(idx, 1);\n }\n }\n}\n\nfunction activateFocusEventOverrides() {\n for (let ev in nonBubblingEventsToRetarget) {\n window.addEventListener(ev, function(e) {\n if (!e['__target']) {\n patchEvent(e);\n retargetNonBubblingEvent(e);\n }\n }, true);\n }\n}\n\nfunction patchEvent(event) {\n event['__target'] = event.target;\n event.__relatedTarget = event.relatedTarget;\n // patch event prototype if we can\n if (utils.settings.hasDescriptors) {\n utils.patchPrototype(event, eventMixin);\n // and fallback to patching instance\n } else {\n utils.extend(event, eventMixin);\n }\n}\n\nlet PatchedEvent = mixinComposedFlag(window.Event);\nlet PatchedCustomEvent = mixinComposedFlag(window.CustomEvent);\nlet PatchedMouseEvent = mixinComposedFlag(window.MouseEvent);\n\nexport function patchEvents() {\n window.Event = PatchedEvent;\n window.CustomEvent = PatchedCustomEvent;\n window.MouseEvent = PatchedMouseEvent;\n activateFocusEventOverrides();\n}\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport * as utils from './utils'\nimport {flush} from './flush'\nimport {dispatchEvent} from './native-methods'\nimport * as mutation from './logical-mutation'\nimport {ActiveElementAccessor, ShadowRootAccessor, patchAccessors} from './patch-accessors'\nimport {addEventListener, removeEventListener} from './patch-events'\nimport {attachShadow, ShadyRoot} from './attach-shadow'\n\nfunction getAssignedSlot(node) {\n mutation.renderRootNode(node);\n return node.__shady && node.__shady.assignedSlot || null;\n}\n\nlet windowMixin = {\n\n addEventListener: addEventListener,\n\n removeEventListener: removeEventListener\n};\n\nlet nodeMixin = {\n\n addEventListener: addEventListener,\n\n removeEventListener: removeEventListener,\n\n appendChild(node) {\n return mutation.insertBefore(this, node);\n },\n\n insertBefore(node, ref_node) {\n return mutation.insertBefore(this, node, ref_node);\n },\n\n removeChild(node) {\n return mutation.removeChild(this, node);\n },\n\n /**\n * @this {Node}\n */\n replaceChild(node, ref_node) {\n this.insertBefore(node, ref_node);\n this.removeChild(ref_node);\n return node;\n },\n\n /**\n * @this {Node}\n */\n cloneNode(deep) {\n return mutation.cloneNode(this, deep);\n },\n\n /**\n * @this {Node}\n */\n getRootNode(options) {\n return mutation.getRootNode(this, options);\n },\n\n /**\n * @this {Node}\n */\n get isConnected() {\n // Fast path for distributed nodes.\n const ownerDocument = this.ownerDocument;\n if (ownerDocument && ownerDocument.contains && ownerDocument.contains(this)) return true;\n const ownerDocumentElement = ownerDocument.documentElement;\n if (ownerDocumentElement && ownerDocumentElement.contains && ownerDocumentElement.contains(this)) return true;\n\n let node = this;\n while (node && !(node instanceof Document)) {\n node = node.parentNode || (node instanceof ShadyRoot ? /** @type {ShadowRoot} */(node).host : undefined);\n }\n return !!(node && node instanceof Document);\n },\n\n /**\n * @this {Node}\n */\n dispatchEvent(event) {\n flush();\n return dispatchEvent.call(this, event);\n }\n\n};\n\n// NOTE: For some reason `Text` redefines `assignedSlot`\nlet textMixin = {\n /**\n * @this {Text}\n */\n get assignedSlot() {\n return getAssignedSlot(this);\n }\n};\n\nlet fragmentMixin = {\n\n // TODO(sorvell): consider doing native QSA and filtering results.\n /**\n * @this {DocumentFragment}\n */\n querySelector(selector) {\n // match selector and halt on first result.\n let result = mutation.query(this, function(n) {\n return utils.matchesSelector(n, selector);\n }, function(n) {\n return Boolean(n);\n })[0];\n return result || null;\n },\n\n /**\n * @this {DocumentFragment}\n */\n querySelectorAll(selector) {\n return mutation.query(this, function(n) {\n return utils.matchesSelector(n, selector);\n });\n }\n\n};\n\nlet slotMixin = {\n\n /**\n * @this {HTMLSlotElement}\n */\n assignedNodes(options) {\n if (this.localName === 'slot') {\n mutation.renderRootNode(this);\n return this.__shady ?\n ((options && options.flatten ? this.__shady.distributedNodes :\n this.__shady.assignedNodes) || []) :\n [];\n }\n }\n\n};\n\nlet elementMixin = utils.extendAll({\n\n /**\n * @this {HTMLElement}\n */\n setAttribute(name, value) {\n mutation.setAttribute(this, name, value);\n },\n\n /**\n * @this {HTMLElement}\n */\n removeAttribute(name) {\n mutation.removeAttribute(this, name);\n },\n\n /**\n * @this {HTMLElement}\n */\n attachShadow(options) {\n return attachShadow(this, options);\n },\n\n /**\n * @this {HTMLElement}\n */\n get slot() {\n return this.getAttribute('slot');\n },\n\n /**\n * @this {HTMLElement}\n */\n set slot(value) {\n this.setAttribute('slot', value);\n },\n\n /**\n * @this {HTMLElement}\n */\n get assignedSlot() {\n return getAssignedSlot(this);\n }\n\n}, fragmentMixin, slotMixin);\n\nObject.defineProperties(elementMixin, ShadowRootAccessor);\n\nlet documentMixin = utils.extendAll({\n /**\n * @this {Document}\n */\n importNode(node, deep) {\n return mutation.importNode(node, deep);\n },\n\n /**\n * @this {Document}\n */\n getElementById(id) {\n return this.querySelector(`#${id}`);\n }\n\n}, fragmentMixin);\n\nObject.defineProperties(documentMixin, {\n '_activeElement': ActiveElementAccessor.activeElement\n});\n\nlet nativeBlur = HTMLElement.prototype.blur;\n\nlet htmlElementMixin = utils.extendAll({\n /**\n * @this {HTMLElement}\n */\n blur() {\n let root = this.shadowRoot;\n let shadowActive = root && root.activeElement;\n if (shadowActive) {\n shadowActive.blur();\n } else {\n nativeBlur.call(this);\n }\n }\n})\n\nfunction patchBuiltin(proto, obj) {\n let n$ = Object.getOwnPropertyNames(obj);\n for (let i=0; i < n$.length; i++) {\n let n = n$[i];\n let d = Object.getOwnPropertyDescriptor(obj, n);\n // NOTE: we prefer writing directly here because some browsers\n // have descriptors that are writable but not configurable (e.g.\n // `appendChild` on older browsers)\n if (d.value) {\n proto[n] = d.value;\n } else {\n Object.defineProperty(proto, n, d);\n }\n }\n}\n\n\n// Apply patches to builtins (e.g. Element.prototype). Some of these patches\n// can be done unconditionally (mostly methods like\n// `Element.prototype.appendChild`) and some can only be done when the browser\n// has proper descriptors on the builtin prototype\n// (e.g. `Element.prototype.firstChild`)`. When descriptors are not available,\n// elements are individually patched when needed (see e.g.\n// `patchInside/OutsideElementAccessors` in `patch-accessors.js`).\nexport function patchBuiltins() {\n let nativeHTMLElement =\n (window['customElements'] && window['customElements']['nativeHTMLElement']) ||\n HTMLElement;\n // These patches can always be done, for all supported browsers.\n patchBuiltin(window.Node.prototype, nodeMixin);\n patchBuiltin(window.Window.prototype, windowMixin);\n patchBuiltin(window.Text.prototype, textMixin);\n patchBuiltin(window.DocumentFragment.prototype, fragmentMixin);\n patchBuiltin(window.Element.prototype, elementMixin);\n patchBuiltin(window.Document.prototype, documentMixin);\n if (window.HTMLSlotElement) {\n patchBuiltin(window.HTMLSlotElement.prototype, slotMixin);\n }\n patchBuiltin(nativeHTMLElement.prototype, htmlElementMixin);\n // These patches can *only* be done\n // on browsers that have proper property descriptors on builtin prototypes.\n // This includes: IE11, Edge, Chrome >= 4?; Safari >= 10, Firefox\n // On older browsers (Chrome <= 4?, Safari 9), a per element patching\n // strategy is used for patching accessors.\n if (utils.settings.hasDescriptors) {\n patchAccessors(window.Node.prototype);\n patchAccessors(window.Text.prototype);\n patchAccessors(window.DocumentFragment.prototype);\n patchAccessors(window.Element.prototype);\n patchAccessors(nativeHTMLElement.prototype);\n patchAccessors(window.Document.prototype);\n if (window.HTMLSlotElement) {\n patchAccessors(window.HTMLSlotElement.prototype);\n }\n }\n}\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n/**\n * Patches elements that interacts with ShadyDOM\n * such that tree traversal and mutation apis act like they would under\n * ShadowDOM.\n *\n * This import enables seemless interaction with ShadyDOM powered\n * custom elements, enabling better interoperation with 3rd party code,\n * libraries, and frameworks that use DOM tree manipulation apis.\n */\n\n'use strict';\nimport * as utils from './utils'\nimport {flush, enqueue} from './flush'\nimport {observeChildren, unobserveChildren, filterMutations} from './observe-changes'\nimport * as nativeMethods from './native-methods'\nimport * as nativeTree from './native-tree'\nimport {patchBuiltins} from './patch-builtins'\nimport {patchEvents} from './patch-events'\nimport {ShadyRoot} from './attach-shadow'\n\nif (utils.settings.inUse) {\n let ShadyDOM = {\n // TODO(sorvell): remove when Polymer does not depend on this.\n 'inUse': utils.settings.inUse,\n // TODO(sorvell): remove when Polymer does not depend on this\n 'patch': (node) => node,\n 'isShadyRoot': utils.isShadyRoot,\n 'enqueue': enqueue,\n 'flush': flush,\n 'settings': utils.settings,\n 'filterMutations': filterMutations,\n 'observeChildren': observeChildren,\n 'unobserveChildren': unobserveChildren,\n 'nativeMethods': nativeMethods,\n 'nativeTree': nativeTree\n };\n\n window['ShadyDOM'] = ShadyDOM;\n\n // Apply patches to events...\n patchEvents();\n // Apply patches to builtins (e.g. Element.prototype) where applicable.\n patchBuiltins();\n\n window.ShadowRoot = ShadyRoot;\n}"]} \ No newline at end of file +{"version":3,"sources":["src/array-splice.js","src/utils.js","src/flush.js","src/innerHTML.js","src/native-tree.js","src/patch-accessors.js","src/logical-tree.js","src/native-methods.js","src/distributor.js","src/attach-shadow.js","src/logical-mutation.js","src/observe-changes.js","src/patch-events.js","src/patch-builtins.js","src/shadydom.js"],"names":["newSplice$$module$$src$array_splice","newSplice","index","addedCount","removed","calcSplices$$module$$src$array_splice","calcSplices","current","currentEnd","old","oldEnd","prefixCount","suffixCount","minLength","Math","min","currentStart","oldStart","i","currentValue","previousValue","length","index1","index2","count","equals","splice","push","rowCount","columnCount","distances","Array","j","north","west","edits","northWest","EDIT_LEAVE","EDIT_UPDATE","EDIT_DELETE","EDIT_ADD","reverse","undefined","splices","oldIndex","equals$$module$$src$array_splice","settings","window","hasNativeShadowDOM","attachShadow","Element","prototype","getRootNode","Node","desc","Object","getOwnPropertyDescriptor","hasDescriptors","configurable","get","inUse","isShadyRoot$$module$$src$utils","isShadyRoot","obj","__localName","ownerShadyRootForNode$$module$$src$utils","ownerShadyRootForNode","node","root","p","matches","matchesSelector","mozMatchesSelector","msMatchesSelector","oMatchesSelector","webkitMatchesSelector","extend$$module$$src$utils","extend","target","source","n$","getOwnPropertyNames","n","pd","defineProperty","extendAll$$module$$src$utils","extendAll","sources","mixin$$module$$src$utils","mixin","twiddle","document","createTextNode","content","queue","observe","MutationObserver","shift","e","textContent","characterData","microtask$$module$$src$utils","microtask","callback","flushList","scheduled","enqueue$$module$$src$flush","enqueue","flush","flush$$module$$src$flush","didFlush","escapeAttrRegExp","escapeDataRegExp","escapeReplace$$module$$src$innerHTML","escapeReplace","c","makeSet$$module$$src$innerHTML","makeSet","arr","set","voidElements","plaintextParents","getInnerHTML$$module$$src$innerHTML","getInnerHTML","localName","s","c$","childNodes","l","child","attr","nodeType","ELEMENT_NODE","tagName","attrs","attributes","name","value","replace","TEXT_NODE","data","parentNode","COMMENT_NODE","console","error","Error","nodeWalker","createTreeWalker","NodeFilter","SHOW_ALL","elementWalker","SHOW_ELEMENT","childNodes$$module$$src$native_tree","nodes","currentNode","firstChild","nextSibling","module$$src$native_tree","parentNode$$module$$src$native_tree","firstChild$$module$$src$native_tree","lastChild","lastChild$$module$$src$native_tree","previousSibling","previousSibling$$module$$src$native_tree","nextSibling$$module$$src$native_tree","parentElement","parentElement$$module$$src$native_tree","firstElementChild","firstElementChild$$module$$src$native_tree","lastElementChild","lastElementChild$$module$$src$native_tree","previousElementSibling","previousElementSibling$$module$$src$native_tree","nextElementSibling","nextElementSibling$$module$$src$native_tree","children","children$$module$$src$native_tree","innerHTML","innerHTML$$module$$src$native_tree","textContent$$module$$src$native_tree","nodeValue","textWalker","SHOW_TEXT","nextNode","nativeInnerHTMLDesc","HTMLElement","htmlContainer","implementation","createHTMLDocument","inertDoc","createElement","nativeActiveElementDescriptor","Document","OutsideAccessors","__shady","className","getAttribute","setAttribute","InsideAccessors","item","childNodes.item","childElementCount","tc","cn","join","text","removeChild","appendChild","filter","call","children.item","ShadowRootAccessor","shadowRoot","ActiveElementAccessor","activeElement","active","host","contains","activeRoot","patchAccessorGroup$$module$$src$patch_accessors","patchAccessorGroup","descriptors","force","objDesc","warn","patchAccessors$$module$$src$patch_accessors","patchAccessors","proto","patchOutsideElementAccessors","element","__outsideAccessors","patchInsideElementAccessors","__insideAccessors","linkNode$$module$$src$logical_tree","linkNode","container","ref_node","ps","ns","recordChildNodes$$module$$src$logical_tree","insertBefore","removeAttribute","cloneNode","importNode","addEventListener","removeEventListener","windowAddEventListener","Window","windowRemoveEventListener","dispatchEvent","module$$src$native_methods","NormalizedEvent","Event","inType","params","createEvent","initEvent","bubbles","cancelable","constructor","insertionPointTag","distribute","hasInsertionPoint","pool","dirtyRoots","p$","_getInsertionPoints","prevAssignedNodes","insertionPoint","assignedNodes","clearAssignedSlots","needsSlotChange","anyDistributed","slotName","trim","slot","_prevAssignedSlot","assignedSlot","distributedNodes","d$","_fireSlotChange","distributeInsertionPoint","parent","savePrevious","isFinalDestination","ShadyRootConstructionToken","ShadyRoot$$module$$src$attach_shadow","token","TypeError","createDocumentFragment","__proto__","ShadyRoot","recordChildNodes","_renderPending","_changePending","_distributor","$jscompDefaultExport","update","create","DocumentFragment","ShadyRoot$$module$$src$attach_shadow.prototype.update","render","ShadyRoot$$module$$src$attach_shadow.prototype.render","renderRoot","_getRenderRoot","_skipUpdateInsertionPoints","updateInsertionPoints","_updateChildNodes","compose","_composeNode","ShadyRoot$$module$$src$attach_shadow.prototype.distribute","ShadyRoot$$module$$src$attach_shadow.prototype.updateInsertionPoints","i$","_insertionPoints","querySelectorAll","ShadyRoot$$module$$src$attach_shadow.prototype._composeNode","distributedNode","ShadyRoot$$module$$src$attach_shadow.prototype.isFinalDestination","ShadyRoot$$module$$src$attach_shadow.prototype._updateChildNodes","composed","d","next","ShadyRoot$$module$$src$attach_shadow.prototype.hasInsertionPoint","ShadyRoot$$module$$src$attach_shadow.prototype._getInsertionPoints","ShadyRoot$$module$$src$attach_shadow.prototype.addEventListener","type","fn","optionsOrCapture","capture","__shadyTarget","ShadyRoot$$module$$src$attach_shadow.prototype.removeEventListener","getElementById","ShadyRoot$$module$$src$attach_shadow.prototype.getElementById","id","querySelector","removeNode$$module$$src$logical_mutation","removeNode","logicalParent","distributed","ownerRoot","maybeDistributeParent","hostNeedsDist","ip$","dc$","flatten","addedInsertionPoint","removedDistributed","updateRootViaContentChange","_removeOwnerShadyRoot","_scheduleObserver$$module$$src$logical_mutation","_scheduleObserver","addedNode","removedNode","observer","addedNodes","removedNodes","schedule","getRootNode$$module$$src$logical_mutation","ownerShadyRoot","documentElement","_maybeAddInsertionPoint$$module$$src$logical_mutation","_maybeAddInsertionPoint","added","DOCUMENT_FRAGMENT_NODE","np","na","_nodeNeedsDistribution$$module$$src$logical_mutation","_nodeNeedsDistribution","_removeOwnerShadyRoot$$module$$src$logical_mutation","maybeDistributeParent$$module$$src$logical_mutation","updateRootViaContentChange$$module$$src$logical_mutation","distributeAttributeChange$$module$$src$logical_mutation","distributeAttributeChange","query$$module$$src$logical_mutation","query","matcher","halter","list","_queryElements","_queryElements$$module$$src$logical_mutation","elements","result","scopingShim","insertBefore$$module$$src$logical_mutation","ipAdded","resetTo","fragContent","wrappedContent","hasContent","needsDist","handled","importNode$$module$$src$logical_mutation","deep","ownerDocument","nc","AsyncObserver","_scheduled","callbacks","Set","mutations","takeRecords","forEach","cb","observeChildren$$module$$src$observe_changes","add","_callback","_observer","_node","unobserveChildren$$module$$src$observe_changes","handle","delete","size","filterMutations$$module$$src$observe_changes","filterMutations","targetRootNode","map","mutation","mutationInScope","from","m","alwaysComposed","pathComposer$$module$$src$patch_events","pathComposer","startNode","composedPath","startRoot","retarget$$module$$src$patch_events","retarget","refNode","path","refNodePath","ancestor","lastRoot","rootIdx","indexOf","eventMixin","isTrusted","__composed","__composedPath","currentTarget","relatedTarget","__relatedTarget","__relatedTargetComposedPath","stopPropagation","__propagationStopped","stopImmediatePropagation","__immediatePropagationStopped","mixinComposedFlag$$module$$src$patch_events","mixinComposedFlag","Base","klazz","options","event","nonBubblingEventsToRetarget","fireHandlers$$module$$src$patch_events","fireHandlers","phase","hs","__handlers","retargetNonBubblingEvent$$module$$src$patch_events","retargetNonBubblingEvent","AT_TARGET","lastFiredRoot","findListener$$module$$src$patch_events","findListener","wrappers","once","passive","savedType","savedListener","savedCapture","savedOnce","savedPassive","savedNode","addEventListener$$module$$src$patch_events","fnOrObj","context","__eventWrappers","wrapperFn","patchEvent","lastCurrentTargetDesc","eventPhase","BUBBLING_PHASE","CAPTURING_PHASE","ret","handleEvent","ael","removeEventListener$$module$$src$patch_events","idx","rel","activateFocusEventOverrides$$module$$src$patch_events","activateFocusEventOverrides","ev","patchEvent$$module$$src$patch_events","getPrototypeOf","hasOwnProperty","patchProto","__sourceProto","PatchedEvent","PatchedCustomEvent","CustomEvent","PatchedMouseEvent","MouseEvent","getAssignedSlot$$module$$src$patch_builtins","getAssignedSlot","windowMixin","nodeMixin","nativeParent","replaceChild","isConnected","ownerDocumentElement","textMixin","fragmentMixin","selector","slotMixin","elementMixin","defineProperties","documentMixin","nativeBlur","blur","htmlElementMixin","shadowActive","patchBuiltin$$module$$src$patch_builtins","patchBuiltin","ShadyDOM","patch","observeChildren","unobserveChildren","nativeHTMLElement","Text","HTMLSlotElement","ShadowRoot"],"mappings":"A;;;;;;;;;;aAYAA,QAASC,EAAS,CAACC,CAAD,CAAiBC,CAAjB,CAA6B,CAC7C,MAAO,CACLD,MAAOA,CADF,CAELE,EAwJiCA,EA1J5B,CAGLD,EAAYA,CAHP,CADsC;AAqI/CE,QAASC,GAAW,CAACC,CAAD,CAAwBC,CAAxB,CACEC,CADF,CACiBC,CADjB,CACyB,CAuGf,IAAA,EAAA,CAAA,CAA6B,EAAA,CAA7B,CAtGxBC,EAAc,CAsGU,CArGxBC,EAAc,CAqGU,CAlGxBC,EAAYC,IAAAC,IAAA,CAASP,CAAT,CAAsBQ,CAAtB,CAAoCN,CAApC,CAA6CO,CAA7C,CAChB,IAAoB,CAApB,EAAID,CA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QS1d,EYgRLW,EAAJ,GRwIcyK,CQvIZ,CAAenL,MAAAM,KAAAF,UAAf,CAMA,CRiIY+K,CQtIZ,CAAenL,MAAAke,KAAA9d,UAAf,CAKA,CRiIY+K,CQrIZ,CAAenL,MAAA4P,iBAAAxP,UAAf,CAIA,CRiIY+K,CQpIZ,CAAenL,MAAAG,QAAAC,UAAf,CAGA,CRiIY+K,CQnIZ,CAAe8S,EAAA7d,UAAf,CAEA,CRiIY+K,CQlIZ,CAAenL,MAAAiJ,SAAA7I,UAAf,CACA,CAAIJ,MAAAme,gBAAJ,ERiIYhT,CQhIV,CAAenL,MAAAme,gBAAA/d,UAAf,CARJ,CCtOAJ,OAAAoe,WAAA,CLvBShP,CKDe","file":"shadydom.min.js","sourcesContent":["/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nfunction newSplice(index, removed, addedCount) {\n return {\n index: index,\n removed: removed,\n addedCount: addedCount\n };\n}\n\nconst EDIT_LEAVE = 0;\nconst EDIT_UPDATE = 1;\nconst EDIT_ADD = 2;\nconst EDIT_DELETE = 3;\n\n// Note: This function is *based* on the computation of the Levenshtein\n// \"edit\" distance. The one change is that \"updates\" are treated as two\n// edits - not one. With Array splices, an update is really a delete\n// followed by an add. By retaining this, we optimize for \"keeping\" the\n// maximum array items in the original array. For example:\n//\n// 'xxxx123' -> '123yyyy'\n//\n// With 1-edit updates, the shortest path would be just to update all seven\n// characters. With 2-edit updates, we delete 4, leave 3, and add 4. This\n// leaves the substring '123' intact.\nfunction calcEditDistances(current, currentStart, currentEnd,\n old, oldStart, oldEnd) {\n // \"Deletion\" columns\n let rowCount = oldEnd - oldStart + 1;\n let columnCount = currentEnd - currentStart + 1;\n let distances = new Array(rowCount);\n\n // \"Addition\" rows. Initialize null column.\n for (let i = 0; i < rowCount; i++) {\n distances[i] = new Array(columnCount);\n distances[i][0] = i;\n }\n\n // Initialize null row\n for (let j = 0; j < columnCount; j++)\n distances[0][j] = j;\n\n for (let i = 1; i < rowCount; i++) {\n for (let j = 1; j < columnCount; j++) {\n if (equals(current[currentStart + j - 1], old[oldStart + i - 1]))\n distances[i][j] = distances[i - 1][j - 1];\n else {\n let north = distances[i - 1][j] + 1;\n let west = distances[i][j - 1] + 1;\n distances[i][j] = north < west ? north : west;\n }\n }\n }\n\n return distances;\n}\n\n// This starts at the final weight, and walks \"backward\" by finding\n// the minimum previous weight recursively until the origin of the weight\n// matrix.\nfunction spliceOperationsFromEditDistances(distances) {\n let i = distances.length - 1;\n let j = distances[0].length - 1;\n let current = distances[i][j];\n let edits = [];\n while (i > 0 || j > 0) {\n if (i == 0) {\n edits.push(EDIT_ADD);\n j--;\n continue;\n }\n if (j == 0) {\n edits.push(EDIT_DELETE);\n i--;\n continue;\n }\n let northWest = distances[i - 1][j - 1];\n let west = distances[i - 1][j];\n let north = distances[i][j - 1];\n\n let min;\n if (west < north)\n min = west < northWest ? west : northWest;\n else\n min = north < northWest ? north : northWest;\n\n if (min == northWest) {\n if (northWest == current) {\n edits.push(EDIT_LEAVE);\n } else {\n edits.push(EDIT_UPDATE);\n current = northWest;\n }\n i--;\n j--;\n } else if (min == west) {\n edits.push(EDIT_DELETE);\n i--;\n current = west;\n } else {\n edits.push(EDIT_ADD);\n j--;\n current = north;\n }\n }\n\n edits.reverse();\n return edits;\n}\n\n/**\n * Splice Projection functions:\n *\n * A splice map is a representation of how a previous array of items\n * was transformed into a new array of items. Conceptually it is a list of\n * tuples of\n *\n * \n *\n * which are kept in ascending index order of. The tuple represents that at\n * the |index|, |removed| sequence of items were removed, and counting forward\n * from |index|, |addedCount| items were added.\n */\n\n/**\n * Lacking individual splice mutation information, the minimal set of\n * splices can be synthesized given the previous state and final state of an\n * array. The basic approach is to calculate the edit distance matrix and\n * choose the shortest path through it.\n *\n * Complexity: O(l * p)\n * l: The length of the current array\n * p: The length of the old array\n */\nfunction calcSplices(current, currentStart, currentEnd,\n old, oldStart, oldEnd) {\n let prefixCount = 0;\n let suffixCount = 0;\n let splice;\n\n let minLength = Math.min(currentEnd - currentStart, oldEnd - oldStart);\n if (currentStart == 0 && oldStart == 0)\n prefixCount = sharedPrefix(current, old, minLength);\n\n if (currentEnd == current.length && oldEnd == old.length)\n suffixCount = sharedSuffix(current, old, minLength - prefixCount);\n\n currentStart += prefixCount;\n oldStart += prefixCount;\n currentEnd -= suffixCount;\n oldEnd -= suffixCount;\n\n if (currentEnd - currentStart == 0 && oldEnd - oldStart == 0)\n return [];\n\n if (currentStart == currentEnd) {\n splice = newSplice(currentStart, [], 0);\n while (oldStart < oldEnd)\n splice.removed.push(old[oldStart++]);\n\n return [ splice ];\n } else if (oldStart == oldEnd)\n return [ newSplice(currentStart, [], currentEnd - currentStart) ];\n\n let ops = spliceOperationsFromEditDistances(\n calcEditDistances(current, currentStart, currentEnd,\n old, oldStart, oldEnd));\n\n splice = undefined;\n let splices = [];\n let index = currentStart;\n let oldIndex = oldStart;\n for (let i = 0; i < ops.length; i++) {\n switch(ops[i]) {\n case EDIT_LEAVE:\n if (splice) {\n splices.push(splice);\n splice = undefined;\n }\n\n index++;\n oldIndex++;\n break;\n case EDIT_UPDATE:\n if (!splice)\n splice = newSplice(index, [], 0);\n\n splice.addedCount++;\n index++;\n\n splice.removed.push(old[oldIndex]);\n oldIndex++;\n break;\n case EDIT_ADD:\n if (!splice)\n splice = newSplice(index, [], 0);\n\n splice.addedCount++;\n index++;\n break;\n case EDIT_DELETE:\n if (!splice)\n splice = newSplice(index, [], 0);\n\n splice.removed.push(old[oldIndex]);\n oldIndex++;\n break;\n }\n }\n\n if (splice) {\n splices.push(splice);\n }\n return splices;\n}\n\nfunction sharedPrefix(current, old, searchLength) {\n for (let i = 0; i < searchLength; i++)\n if (!equals(current[i], old[i]))\n return i;\n return searchLength;\n}\n\nfunction sharedSuffix(current, old, searchLength) {\n let index1 = current.length;\n let index2 = old.length;\n let count = 0;\n while (count < searchLength && equals(current[--index1], old[--index2]))\n count++;\n\n return count;\n}\n\nfunction equals(currentValue, previousValue) {\n return currentValue === previousValue;\n}\n\nexport function calculateSplices(current, previous) {\n return calcSplices(current, 0, current.length, previous, 0,\n previous.length);\n}\n\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nexport let settings = window['ShadyDOM'] || {};\n\nsettings.hasNativeShadowDOM = Boolean(Element.prototype.attachShadow && Node.prototype.getRootNode);\n\nlet desc = Object.getOwnPropertyDescriptor(Node.prototype, 'firstChild');\n\nsettings.hasDescriptors = Boolean(desc && desc.configurable && desc.get);\nsettings.inUse = settings['force'] || !settings.hasNativeShadowDOM;\n\nexport function isShadyRoot(obj) {\n return Boolean(obj.__localName === 'ShadyRoot');\n}\n\nexport function ownerShadyRootForNode(node) {\n let root = node.getRootNode();\n if (isShadyRoot(root)) {\n return root;\n }\n}\n\nlet p = Element.prototype;\nlet matches = p.matches || p.matchesSelector ||\n p.mozMatchesSelector || p.msMatchesSelector ||\n p.oMatchesSelector || p.webkitMatchesSelector;\n\nexport function matchesSelector(element, selector) {\n return matches.call(element, selector);\n}\n\nfunction copyOwnProperty(name, source, target) {\n let pd = Object.getOwnPropertyDescriptor(source, name);\n if (pd) {\n Object.defineProperty(target, name, pd);\n }\n}\n\nexport function extend(target, source) {\n if (target && source) {\n let n$ = Object.getOwnPropertyNames(source);\n for (let i=0, n; (i {\n while (queue.length) {\n // catch errors in user code...\n try {\n queue.shift()();\n } catch(e) {\n // enqueue another record and throw\n twiddle.textContent = content++;\n throw(e);\n }\n }\n}).observe(twiddle, {characterData: true});\n\n// use MutationObserver to get microtask async timing.\nexport function microtask(callback) {\n queue.push(callback);\n twiddle.textContent = content++;\n}","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport * as utils from './utils'\n\n// render enqueuer/flusher\nlet flushList = [];\nlet scheduled;\nexport function enqueue(callback) {\n if (!scheduled) {\n scheduled = true;\n utils.microtask(flush);\n }\n flushList.push(callback);\n}\n\nexport function flush() {\n scheduled = false;\n let didFlush = Boolean(flushList.length);\n while (flushList.length) {\n flushList.shift()();\n }\n return didFlush;\n}\n\nflush['list'] = flushList;","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\n// Cribbed from ShadowDOM polyfill\n// https://github.com/webcomponents/webcomponentsjs/blob/master/src/ShadowDOM/wrappers/HTMLElement.js#L28\n/////////////////////////////////////////////////////////////////////////////\n// innerHTML and outerHTML\n\n// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#escapingString\nlet escapeAttrRegExp = /[&\\u00A0\"]/g;\nlet escapeDataRegExp = /[&\\u00A0<>]/g;\n\nfunction escapeReplace(c) {\n switch (c) {\n case '&':\n return '&';\n case '<':\n return '<';\n case '>':\n return '>';\n case '\"':\n return '"';\n case '\\u00A0':\n return ' ';\n }\n}\n\nfunction escapeAttr(s) {\n return s.replace(escapeAttrRegExp, escapeReplace);\n}\n\nfunction escapeData(s) {\n return s.replace(escapeDataRegExp, escapeReplace);\n}\n\nfunction makeSet(arr) {\n let set = {};\n for (let i = 0; i < arr.length; i++) {\n set[arr[i]] = true;\n }\n return set;\n}\n\n// http://www.whatwg.org/specs/web-apps/current-work/#void-elements\nlet voidElements = makeSet([\n 'area',\n 'base',\n 'br',\n 'col',\n 'command',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'keygen',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr'\n]);\n\nlet plaintextParents = makeSet([\n 'style',\n 'script',\n 'xmp',\n 'iframe',\n 'noembed',\n 'noframes',\n 'plaintext',\n 'noscript'\n]);\n\n/**\n * @param {Node} node\n * @param {Node} parentNode\n * @param {Function=} callback\n */\nexport function getOuterHTML(node, parentNode, callback) {\n switch (node.nodeType) {\n case Node.ELEMENT_NODE: {\n let tagName = node.localName;\n let s = '<' + tagName;\n let attrs = node.attributes;\n for (let i = 0, attr; (attr = attrs[i]); i++) {\n s += ' ' + attr.name + '=\"' + escapeAttr(attr.value) + '\"';\n }\n s += '>';\n if (voidElements[tagName]) {\n return s;\n }\n return s + getInnerHTML(node, callback) + '';\n }\n case Node.TEXT_NODE: {\n let data = /** @type {Text} */ (node).data;\n if (parentNode && plaintextParents[parentNode.localName]) {\n return data;\n }\n return escapeData(data);\n }\n case Node.COMMENT_NODE: {\n return '';\n }\n default: {\n window.console.error(node);\n throw new Error('not implemented');\n }\n }\n}\n\n/**\n * @param {Node} node\n * @param {Function=} callback\n */\nexport function getInnerHTML(node, callback) {\n if (node.localName === 'template') {\n node = /** @type {HTMLTemplateElement} */ (node).content;\n }\n let s = '';\n let c$ = callback ? callback(node) : node.childNodes;\n for (let i=0, l=c$.length, child; (i childNodes(n));\n}\n\nexport function textContent(node) {\n if (node.nodeType !== Node.ELEMENT_NODE) {\n return node.nodeValue;\n }\n let textWalker = document.createTreeWalker(node, NodeFilter.SHOW_TEXT,\n null, false);\n let content = '', n;\n while ( (n = textWalker.nextNode()) ) {\n // TODO(sorvell): can't use textContent since we patch it on Node.prototype!\n // However, should probably patch it only on element.\n content += n.nodeValue;\n }\n return content;\n}","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport * as utils from './utils'\nimport {getInnerHTML} from './innerHTML'\nimport * as nativeTree from './native-tree'\n\nfunction clearNode(node) {\n while (node.firstChild) {\n node.removeChild(node.firstChild);\n }\n}\n\nconst nativeInnerHTMLDesc = /** @type {ObjectPropertyDescriptor} */(\n Object.getOwnPropertyDescriptor(Element.prototype, 'innerHTML') ||\n Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'innerHTML'));\n\nconst inertDoc = document.implementation.createHTMLDocument('inert');\nconst htmlContainer = inertDoc.createElement('div');\n\nconst nativeActiveElementDescriptor =\n /** @type {ObjectPropertyDescriptor} */(\n Object.getOwnPropertyDescriptor(Document.prototype, 'activeElement')\n );\nfunction getDocumentActiveElement() {\n if (nativeActiveElementDescriptor && nativeActiveElementDescriptor.get) {\n return nativeActiveElementDescriptor.get.call(document);\n } else if (!utils.settings.hasDescriptors) {\n return document.activeElement;\n }\n}\n\nfunction activeElementForNode(node) {\n let active = getDocumentActiveElement();\n // In IE11, activeElement might be an empty object if the document is\n // contained in an iframe.\n // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10998788/\n if (!active || !active.nodeType) {\n return null;\n }\n let isShadyRoot = !!(utils.isShadyRoot(node));\n if (node !== document) {\n // If this node isn't a document or shady root, then it doesn't have\n // an active element.\n if (!isShadyRoot) {\n return null;\n }\n // If this shady root's host is the active element or the active\n // element is not a descendant of the host (in the composed tree),\n // then it doesn't have an active element.\n if (node.host === active ||\n !node.host.contains(active)) {\n return null;\n }\n }\n // This node is either the document or a shady root of which the active\n // element is a (composed) descendant of its host; iterate upwards to\n // find the active element's most shallow host within it.\n let activeRoot = utils.ownerShadyRootForNode(active);\n while (activeRoot && activeRoot !== node) {\n active = activeRoot.host;\n activeRoot = utils.ownerShadyRootForNode(active);\n }\n if (node === document) {\n // This node is the document, so activeRoot should be null.\n return activeRoot ? null : active;\n } else {\n // This node is a non-document shady root, and it should be\n // activeRoot.\n return activeRoot === node ? active : null;\n }\n}\n\nlet OutsideAccessors = {\n\n parentElement: {\n /** @this {Node} */\n get() {\n let l = this.__shady && this.__shady.parentNode;\n if (l && l.nodeType !== Node.ELEMENT_NODE) {\n l = null;\n }\n return l !== undefined ? l : nativeTree.parentElement(this);\n },\n configurable: true\n },\n\n parentNode: {\n /** @this {Node} */\n get() {\n let l = this.__shady && this.__shady.parentNode;\n return l !== undefined ? l : nativeTree.parentNode(this);\n },\n configurable: true\n },\n\n nextSibling: {\n /** @this {Node} */\n get() {\n let l = this.__shady && this.__shady.nextSibling;\n return l !== undefined ? l : nativeTree.nextSibling(this);\n },\n configurable: true\n },\n\n previousSibling: {\n /** @this {Node} */\n get() {\n let l = this.__shady && this.__shady.previousSibling;\n return l !== undefined ? l : nativeTree.previousSibling(this);\n },\n configurable: true\n },\n\n className: {\n /**\n * @this {HTMLElement}\n */\n get() {\n return this.getAttribute('class') || '';\n },\n /**\n * @this {HTMLElement}\n */\n set(value) {\n this.setAttribute('class', value);\n },\n configurable: true\n },\n\n // fragment, element, document\n nextElementSibling: {\n /**\n * @this {HTMLElement}\n */\n get() {\n if (this.__shady && this.__shady.nextSibling !== undefined) {\n let n = this.nextSibling;\n while (n && n.nodeType !== Node.ELEMENT_NODE) {\n n = n.nextSibling;\n }\n return n;\n } else {\n return nativeTree.nextElementSibling(this);\n }\n },\n configurable: true\n },\n\n previousElementSibling: {\n /**\n * @this {HTMLElement}\n */\n get() {\n if (this.__shady && this.__shady.previousSibling !== undefined) {\n let n = this.previousSibling;\n while (n && n.nodeType !== Node.ELEMENT_NODE) {\n n = n.previousSibling;\n }\n return n;\n } else {\n return nativeTree.previousElementSibling(this);\n }\n },\n configurable: true\n }\n\n};\n\nlet InsideAccessors = {\n\n childNodes: {\n /**\n * @this {HTMLElement}\n */\n get() {\n let childNodes;\n if (this.__shady && this.__shady.firstChild !== undefined) {\n if (!this.__shady.childNodes) {\n this.__shady.childNodes = [];\n for (let n=this.firstChild; n; n=n.nextSibling) {\n this.__shady.childNodes.push(n);\n }\n }\n childNodes = this.__shady.childNodes;\n } else {\n childNodes = nativeTree.childNodes(this);\n }\n childNodes.item = function(index) {\n return childNodes[index];\n }\n return childNodes;\n },\n configurable: true\n },\n\n childElementCount: {\n /** @this {HTMLElement} */\n get() {\n return this.children.length;\n },\n configurable: true\n },\n\n firstChild: {\n /** @this {HTMLElement} */\n get() {\n let l = this.__shady && this.__shady.firstChild;\n return l !== undefined ? l : nativeTree.firstChild(this);\n },\n configurable: true\n },\n\n lastChild: {\n /** @this {HTMLElement} */\n get() {\n let l = this.__shady && this.__shady.lastChild;\n return l !== undefined ? l : nativeTree.lastChild(this);\n },\n configurable: true\n },\n\n textContent: {\n /**\n * @this {HTMLElement}\n */\n get() {\n if (this.__shady && this.__shady.firstChild !== undefined) {\n let tc = [];\n for (let i = 0, cn = this.childNodes, c; (c = cn[i]); i++) {\n if (c.nodeType !== Node.COMMENT_NODE) {\n tc.push(c.textContent);\n }\n }\n return tc.join('');\n } else {\n return nativeTree.textContent(this);\n }\n },\n /**\n * @this {HTMLElement}\n */\n set(text) {\n if (this.nodeType !== Node.ELEMENT_NODE) {\n // TODO(sorvell): can't do this if patch nodeValue.\n this.nodeValue = text;\n } else {\n clearNode(this);\n this.appendChild(document.createTextNode(text));\n }\n },\n configurable: true\n },\n\n // fragment, element, document\n firstElementChild: {\n /**\n * @this {HTMLElement}\n */\n get() {\n if (this.__shady && this.__shady.firstChild !== undefined) {\n let n = this.firstChild;\n while (n && n.nodeType !== Node.ELEMENT_NODE) {\n n = n.nextSibling;\n }\n return n;\n } else {\n return nativeTree.firstElementChild(this);\n }\n },\n configurable: true\n },\n\n lastElementChild: {\n /**\n * @this {HTMLElement}\n */\n get() {\n if (this.__shady && this.__shady.lastChild !== undefined) {\n let n = this.lastChild;\n while (n && n.nodeType !== Node.ELEMENT_NODE) {\n n = n.previousSibling;\n }\n return n;\n } else {\n return nativeTree.lastElementChild(this);\n }\n },\n configurable: true\n },\n\n children: {\n /**\n * @this {HTMLElement}\n */\n get() {\n let children;\n if (this.__shady && this.__shady.firstChild !== undefined) {\n children = Array.prototype.filter.call(this.childNodes, function(n) {\n return (n.nodeType === Node.ELEMENT_NODE);\n });\n } else {\n children = nativeTree.children(this);\n }\n children.item = function(index) {\n return children[index];\n }\n return children;\n },\n configurable: true\n },\n\n // element (HTMLElement on IE11)\n innerHTML: {\n /**\n * @this {HTMLElement}\n */\n get() {\n let content = this.localName === 'template' ?\n /** @type {HTMLTemplateElement} */(this).content : this;\n if (this.__shady && this.__shady.firstChild !== undefined) {\n return getInnerHTML(content);\n } else {\n return nativeTree.innerHTML(content);\n }\n },\n /**\n * @this {HTMLElement}\n */\n set(text) {\n let content = this.localName === 'template' ?\n /** @type {HTMLTemplateElement} */(this).content : this;\n clearNode(content);\n if (nativeInnerHTMLDesc && nativeInnerHTMLDesc.set) {\n nativeInnerHTMLDesc.set.call(htmlContainer, text);\n } else {\n htmlContainer.innerHTML = text;\n }\n while (htmlContainer.firstChild) {\n content.appendChild(htmlContainer.firstChild);\n }\n },\n configurable: true\n }\n\n};\n\n// Note: Can be patched on element prototype on all browsers.\n// Must be patched on instance on browsers that support native Shadow DOM\n// but do not have builtin accessors (old Chrome).\nexport let ShadowRootAccessor = {\n\n shadowRoot: {\n /**\n * @this {HTMLElement}\n */\n get() {\n return this.__shady && this.__shady.root || null;\n },\n /**\n * @this {HTMLElement}\n */\n set(value) {\n this.__shady = this.__shady || {};\n this.__shady.root = value;\n },\n configurable: true\n }\n};\n\n// Note: Can be patched on document prototype on browsers with builtin accessors.\n// Must be patched separately on simulated ShadowRoot.\n// Must be patched as `_activeElement` on browsers without builtin accessors.\nexport let ActiveElementAccessor = {\n\n activeElement: {\n /**\n * @this {HTMLElement}\n */\n get() {\n return activeElementForNode(this);\n },\n /**\n * @this {HTMLElement}\n */\n set() {},\n configurable: true\n }\n\n};\n\n// patch a group of descriptors on an object only if it exists or if the `force`\n// argument is true.\n/**\n * @param {!Object} obj\n * @param {!Object} descriptors\n * @param {boolean=} force\n */\nfunction patchAccessorGroup(obj, descriptors, force) {\n for (let p in descriptors) {\n let objDesc = Object.getOwnPropertyDescriptor(obj, p);\n if ((objDesc && objDesc.configurable) ||\n (!objDesc && force)) {\n Object.defineProperty(obj, p, descriptors[p]);\n } else if (force) {\n console.warn('Could not define', p, 'on', obj);\n }\n }\n}\n\n// patch dom accessors on proto where they exist\nexport function patchAccessors(proto) {\n patchAccessorGroup(proto, OutsideAccessors);\n patchAccessorGroup(proto, InsideAccessors);\n patchAccessorGroup(proto, ActiveElementAccessor);\n}\n\n// ensure element descriptors (IE/Edge don't have em)\nexport function patchShadowRootAccessors(proto) {\n patchAccessorGroup(proto, InsideAccessors, true);\n patchAccessorGroup(proto, ActiveElementAccessor, true);\n}\n\n// ensure an element has patched \"outside\" accessors; no-op when not needed\nexport let patchOutsideElementAccessors = utils.settings.hasDescriptors ?\n function() {} : function(element) {\n if (!(element.__shady && element.__shady.__outsideAccessors)) {\n element.__shady = element.__shady || {};\n element.__shady.__outsideAccessors = true;\n patchAccessorGroup(element, OutsideAccessors, true);\n }\n }\n\n// ensure an element has patched \"inside\" accessors; no-op when not needed\nexport let patchInsideElementAccessors = utils.settings.hasDescriptors ?\n function() {} : function(element) {\n if (!(element.__shady && element.__shady.__insideAccessors)) {\n element.__shady = element.__shady || {};\n element.__shady.__insideAccessors = true;\n patchAccessorGroup(element, InsideAccessors, true);\n patchAccessorGroup(element, ShadowRootAccessor, true);\n }\n }\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport {patchInsideElementAccessors, patchOutsideElementAccessors} from './patch-accessors'\nimport {firstChild, lastChild, childNodes} from './native-tree'\n\nexport function recordInsertBefore(node, container, ref_node) {\n patchInsideElementAccessors(container);\n container.__shady = container.__shady || {};\n if (container.__shady.firstChild !== undefined) {\n container.__shady.childNodes = null;\n }\n // handle document fragments\n if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n let c$ = node.childNodes;\n for (let i=0; i < c$.length; i++) {\n linkNode(c$[i], container, ref_node);\n }\n // cleanup logical dom in doc fragment.\n node.__shady = node.__shady || {};\n let resetTo = (node.__shady.firstChild !== undefined) ? null : undefined;\n node.__shady.firstChild = node.__shady.lastChild = resetTo;\n node.__shady.childNodes = resetTo;\n } else {\n linkNode(node, container, ref_node);\n }\n}\n\nfunction linkNode(node, container, ref_node) {\n patchOutsideElementAccessors(node);\n ref_node = ref_node || null;\n node.__shady = node.__shady || {};\n container.__shady = container.__shady || {};\n if (ref_node) {\n ref_node.__shady = ref_node.__shady || {};\n }\n // update ref_node.previousSibling <-> node\n node.__shady.previousSibling = ref_node ? ref_node.__shady.previousSibling :\n container.lastChild;\n let ps = node.__shady.previousSibling;\n if (ps && ps.__shady) {\n ps.__shady.nextSibling = node;\n }\n // update node <-> ref_node\n let ns = node.__shady.nextSibling = ref_node;\n if (ns && ns.__shady) {\n ns.__shady.previousSibling = node;\n }\n // update node <-> container\n node.__shady.parentNode = container;\n if (ref_node) {\n if (ref_node === container.__shady.firstChild) {\n container.__shady.firstChild = node;\n }\n } else {\n container.__shady.lastChild = node;\n if (!container.__shady.firstChild) {\n container.__shady.firstChild = node;\n }\n }\n // remove caching of childNodes\n container.__shady.childNodes = null;\n}\n\nexport function recordRemoveChild(node, container) {\n node.__shady = node.__shady || {};\n container.__shady = container.__shady || {};\n if (node === container.__shady.firstChild) {\n container.__shady.firstChild = node.__shady.nextSibling;\n }\n if (node === container.__shady.lastChild) {\n container.__shady.lastChild = node.__shady.previousSibling;\n }\n let p = node.__shady.previousSibling;\n let n = node.__shady.nextSibling;\n if (p) {\n p.__shady = p.__shady || {};\n p.__shady.nextSibling = n;\n }\n if (n) {\n n.__shady = n.__shady || {};\n n.__shady.previousSibling = p;\n }\n // When an element is removed, logical data is no longer tracked.\n // Explicitly set `undefined` here to indicate this. This is disginguished\n // from `null` which is set if info is null.\n node.__shady.parentNode = node.__shady.previousSibling =\n node.__shady.nextSibling = undefined;\n if (container.__shady.childNodes !== undefined) {\n // remove caching of childNodes\n container.__shady.childNodes = null;\n }\n}\n\nexport let recordChildNodes = function(node) {\n if (!node.__shady || node.__shady.firstChild === undefined) {\n node.__shady = node.__shady || {};\n node.__shady.firstChild = firstChild(node);\n node.__shady.lastChild = lastChild(node);\n patchInsideElementAccessors(node);\n let c$ = node.__shady.childNodes = childNodes(node);\n for (let i=0, n; (i host\n host.shadowRoot = this;\n this.host = host;\n // state flags\n this._renderPending = false;\n this._hasRendered = false;\n this._changePending = false;\n this._distributor = new Distributor(this);\n this.update();\n}\n\n\n// async render\nShadyRoot.prototype.update = function() {\n if (!this._renderPending) {\n this._renderPending = true;\n enqueue(() => this.render());\n }\n}\n\n// returns the oldest renderPending ancestor root.\nShadyRoot.prototype._getRenderRoot = function() {\n let renderRoot = this;\n let root = this;\n while (root) {\n if (root._renderPending) {\n renderRoot = root;\n }\n root = root._rendererForHost();\n }\n return renderRoot;\n}\n\n// Returns the shadyRoot `this.host` if `this.host`\n// has children that require distribution.\nShadyRoot.prototype._rendererForHost = function() {\n let root = this.host.getRootNode();\n if (utils.isShadyRoot(root)) {\n let c$ = this.host.childNodes;\n for (let i=0, c; i < c$.length; i++) {\n c = c$[i];\n if (this._distributor.isInsertionPoint(c)) {\n return root;\n }\n }\n }\n}\n\nShadyRoot.prototype.render = function() {\n if (this._renderPending) {\n this._getRenderRoot()['_render']();\n }\n}\n\n// NOTE: avoid renaming to ease testability.\nShadyRoot.prototype['_render'] = function() {\n this._renderPending = false;\n this._changePending = false;\n if (!this._skipUpdateInsertionPoints) {\n this.updateInsertionPoints();\n } else if (!this._hasRendered) {\n this.__insertionPoints = [];\n }\n this._skipUpdateInsertionPoints = false;\n // TODO(sorvell): can add a first render optimization here\n // to use if there are no insertion points\n // 1. clear host node of composed children\n // 2. appendChild the shadowRoot itself or (more robust) its logical children\n // NOTE: this didn't seem worth it in perf testing\n // but not ready to delete this info.\n // logical\n this.distribute();\n // physical\n this.compose();\n this._hasRendered = true;\n}\n\nShadyRoot.prototype.forceRender = function() {\n this._renderPending = true;\n this.render();\n}\n\nShadyRoot.prototype.distribute = function() {\n let dirtyRoots = this._distributor.distribute();\n for (let i=0; i children but since this case is assumed to be exceedingly\n // rare, we avoid the cost and will address with some specific api\n // when the need arises. For now, the user must call\n // distributeContent(true), which updates insertion points manually\n // and forces distribution.\n let insertionPointTag = ownerRoot && ownerRoot.getInsertionPointTag() || '';\n let fragContent = (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) &&\n !node['__noInsertionPoint'] &&\n insertionPointTag && node.querySelector(insertionPointTag);\n let wrappedContent = fragContent &&\n (fragContent.parentNode.nodeType !==\n Node.DOCUMENT_FRAGMENT_NODE);\n let hasContent = fragContent || (node.localName === insertionPointTag);\n // There are 3 possible cases where a distribution may need to occur:\n // 1. being inserted (the host of the shady root where\n // content is inserted needs distribution)\n // 2. children being inserted into parent with a shady root (parent\n // needs distribution)\n // 3. container is an insertionPoint\n if (hasContent || (container.localName === insertionPointTag) || ipAdded) {\n if (ownerRoot) {\n // note, insertion point list update is handled after node\n // mutations are complete\n updateRootViaContentChange(ownerRoot);\n }\n }\n let needsDist = _nodeNeedsDistribution(container);\n if (needsDist) {\n let root = container.__shady && container.__shady.root;\n updateRootViaContentChange(root);\n }\n // Return true when distribution will fully handle the composition\n // Note that if a content was being inserted that was wrapped by a node,\n // and the parent does not need distribution, return false to allow\n // the nodes to be added directly, after which children may be\n // distributed and composed into the wrapping node(s)\n return needsDist || (hasContent && !wrappedContent);\n}\n\n/* note: parent argument is required since node may have an out\nof date parent at this point; returns true if a is being added */\nfunction _maybeAddInsertionPoint(node, parent, root) {\n let added;\n let insertionPointTag = root.getInsertionPointTag();\n if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE &&\n !node['__noInsertionPoint']) {\n let c$ = node.querySelectorAll(insertionPointTag);\n for (let i=0, n, np, na; (i (host of container needs distribution)\n/**\n * @param {Node} parent\n * @param {Node} node\n * @param {Node=} ref_node\n */\nexport function insertBefore(parent, node, ref_node) {\n if (ref_node) {\n let p = ref_node.__shady && ref_node.__shady.parentNode;\n if ((p !== undefined && p !== parent) ||\n (p === undefined && parentNode(ref_node) !== parent)) {\n throw Error(`Failed to execute 'insertBefore' on 'Node': The node ` +\n `before which the new node is to be inserted is not a child of this node.`);\n }\n }\n if (ref_node === node) {\n return node;\n }\n // remove node from its current position iff it's in a tree.\n if (node.nodeType !== Node.DOCUMENT_FRAGMENT_NODE) {\n let parent = node.__shady && node.__shady.parentNode;\n removeNodeFromParent(node, parent);\n }\n if (!addNode(parent, node, ref_node)) {\n if (ref_node) {\n // if ref_node is an insertion point replace with first distributed node\n let root = utils.ownerShadyRootForNode(ref_node);\n if (root) {\n ref_node = ref_node.localName === root.getInsertionPointTag() ?\n firstComposedNode(/** @type {!HTMLSlotElement} */(ref_node)) : ref_node;\n }\n }\n // if adding to a shadyRoot, add to host instead\n let container = utils.isShadyRoot(parent) ? /** @type {ShadowRoot} */(parent).host : parent;\n if (ref_node) {\n nativeMethods.insertBefore.call(container, node, ref_node);\n } else {\n nativeMethods.appendChild.call(container, node);\n }\n }\n _scheduleObserver(parent, node);\n return node;\n}\n\n/**\n Removes the given `node` from the element's `lightChildren`.\n This method also performs dom composition.\n*/\nexport function removeChild(parent, node) {\n if (node.parentNode !== parent) {\n throw Error('The node to be removed is not a child of this node: ' +\n node);\n }\n if (!removeNode(node)) {\n // if removing from a shadyRoot, remove form host instead\n let container = utils.isShadyRoot(parent) ?\n parent.host :\n parent;\n // not guaranteed to physically be in container; e.g.\n // undistributed nodes.\n let nativeParent = parentNode(node);\n if (container === nativeParent) {\n nativeMethods.removeChild.call(container, node);\n }\n }\n _scheduleObserver(parent, null, node);\n return node;\n}\n\nexport function cloneNode(node, deep) {\n if (node.localName == 'template') {\n return nativeMethods.cloneNode.call(node, deep);\n } else {\n let n = nativeMethods.cloneNode.call(node, false);\n if (deep) {\n let c$ = node.childNodes;\n for (let i=0, nc; i < c$.length; i++) {\n nc = c$[i].cloneNode(true);\n n.appendChild(nc);\n }\n }\n return n;\n }\n}\n\n// note: Though not technically correct, we fast path `importNode`\n// when called on a node not owned by the main document.\n// This allows, for example, elements that cannot\n// contain custom elements and are therefore not likely to contain shadowRoots\n// to cloned natively. This is a fairly significant performance win.\nexport function importNode(node, deep) {\n if (node.ownerDocument !== document) {\n return nativeMethods.importNode.call(document, node, deep);\n }\n let n = nativeMethods.importNode.call(document, node, false);\n if (deep) {\n let c$ = node.childNodes;\n for (let i=0, nc; i < c$.length; i++) {\n nc = importNode(c$[i], true);\n n.appendChild(nc);\n }\n }\n return n;\n}\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport * as utils from './utils'\n\nclass AsyncObserver {\n\n constructor() {\n this._scheduled = false;\n this.addedNodes = [];\n this.removedNodes = [];\n this.callbacks = new Set();\n }\n\n schedule() {\n if (!this._scheduled) {\n this._scheduled = true;\n utils.microtask(() => {\n this.flush();\n });\n }\n }\n\n flush() {\n if (this._scheduled) {\n this._scheduled = false;\n let mutations = this.takeRecords();\n if (mutations.length) {\n this.callbacks.forEach(function(cb) {\n cb(mutations);\n });\n }\n }\n }\n\n takeRecords() {\n if (this.addedNodes.length || this.removedNodes.length) {\n let mutations = [{\n addedNodes: this.addedNodes,\n removedNodes: this.removedNodes\n }];\n this.addedNodes = [];\n this.removedNodes = [];\n return mutations;\n }\n return [];\n }\n\n}\n\n// TODO(sorvell): consider instead polyfilling MutationObserver\n// directly so that users do not have to fork their code.\n// Supporting the entire api may be challenging: e.g. filtering out\n// removed nodes in the wrong scope and seeing non-distributing\n// subtree child mutations.\nexport let observeChildren = function(node, callback) {\n node.__shady = node.__shady || {};\n if (!node.__shady.observer) {\n node.__shady.observer = new AsyncObserver();\n }\n node.__shady.observer.callbacks.add(callback);\n let observer = node.__shady.observer;\n return {\n _callback: callback,\n _observer: observer,\n _node: node,\n takeRecords() {\n return observer.takeRecords()\n }\n };\n}\n\nexport let unobserveChildren = function(handle) {\n let observer = handle && handle._observer;\n if (observer) {\n observer.callbacks.delete(handle._callback);\n if (!observer.callbacks.size) {\n handle._node.__shady.observer = null;\n }\n }\n}\n\nexport function filterMutations(mutations, target) {\n /** @const {Node} */\n const targetRootNode = target.getRootNode();\n return mutations.map(function(mutation) {\n /** @const {boolean} */\n const mutationInScope = (targetRootNode === mutation.target.getRootNode());\n if (mutationInScope && mutation.addedNodes) {\n let nodes = Array.from(mutation.addedNodes).filter(function(n) {\n return (targetRootNode === n.getRootNode());\n });\n if (nodes.length) {\n mutation = Object.create(mutation);\n Object.defineProperty(mutation, 'addedNodes', {\n value: nodes,\n configurable: true\n });\n return mutation;\n }\n } else if (mutationInScope) {\n return mutation;\n }\n }).filter(function(m) { return m});\n}","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport * as utils from './utils'\nimport * as nativeMethods from './native-methods'\n\n// https://github.com/w3c/webcomponents/issues/513#issuecomment-224183937\nlet alwaysComposed = {\n 'blur': true,\n 'focus': true,\n 'focusin': true,\n 'focusout': true,\n 'click': true,\n 'dblclick': true,\n 'mousedown': true,\n 'mouseenter': true,\n 'mouseleave': true,\n 'mousemove': true,\n 'mouseout': true,\n 'mouseover': true,\n 'mouseup': true,\n 'wheel': true,\n 'beforeinput': true,\n 'input': true,\n 'keydown': true,\n 'keyup': true,\n 'compositionstart': true,\n 'compositionupdate': true,\n 'compositionend': true,\n 'touchstart': true,\n 'touchend': true,\n 'touchmove': true,\n 'touchcancel': true,\n 'pointerover': true,\n 'pointerenter': true,\n 'pointerdown': true,\n 'pointermove': true,\n 'pointerup': true,\n 'pointercancel': true,\n 'pointerout': true,\n 'pointerleave': true,\n 'gotpointercapture': true,\n 'lostpointercapture': true,\n 'dragstart': true,\n 'drag': true,\n 'dragenter': true,\n 'dragleave': true,\n 'dragover': true,\n 'drop': true,\n 'dragend': true,\n 'DOMActivate': true,\n 'DOMFocusIn': true,\n 'DOMFocusOut': true,\n 'keypress': true\n};\n\nfunction pathComposer(startNode, composed) {\n let composedPath = [];\n let current = startNode;\n let startRoot = startNode === window ? window : startNode.getRootNode();\n while (current) {\n composedPath.push(current);\n if (current.assignedSlot) {\n current = current.assignedSlot;\n } else if (current.nodeType === Node.DOCUMENT_FRAGMENT_NODE && current.host && (composed || current !== startRoot)) {\n current = current.host;\n } else {\n current = current.parentNode;\n }\n }\n // event composedPath includes window when startNode's ownerRoot is document\n if (composedPath[composedPath.length - 1] === document) {\n composedPath.push(window);\n }\n return composedPath;\n}\n\nfunction retarget(refNode, path) {\n if (!utils.isShadyRoot) {\n return refNode;\n }\n // If ANCESTOR's root is not a shadow root or ANCESTOR's root is BASE's\n // shadow-including inclusive ancestor, return ANCESTOR.\n let refNodePath = pathComposer(refNode, true);\n let p$ = path;\n for (let i=0, ancestor, lastRoot, root, rootIdx; i < p$.length; i++) {\n ancestor = p$[i];\n root = ancestor === window ? window : ancestor.getRootNode();\n if (root !== lastRoot) {\n rootIdx = refNodePath.indexOf(root);\n lastRoot = root;\n }\n if (!utils.isShadyRoot(root) || rootIdx > -1) {\n return ancestor;\n }\n }\n}\n\nlet eventMixin = {\n\n /**\n * @this {Event}\n */\n get composed() {\n // isTrusted may not exist in this browser, so just check if isTrusted is explicitly false\n if (this.isTrusted !== false && this.__composed === undefined) {\n this.__composed = alwaysComposed[this.type];\n }\n return this.__composed || false;\n },\n\n /**\n * @this {Event}\n */\n composedPath() {\n if (!this.__composedPath) {\n this.__composedPath = pathComposer(this['__target'], this.composed);\n }\n return this.__composedPath;\n },\n\n /**\n * @this {Event}\n */\n get target() {\n return retarget(this.currentTarget, this.composedPath());\n },\n\n // http://w3c.github.io/webcomponents/spec/shadow/#event-relatedtarget-retargeting\n /**\n * @this {Event}\n */\n get relatedTarget() {\n if (!this.__relatedTarget) {\n return null;\n }\n if (!this.__relatedTargetComposedPath) {\n this.__relatedTargetComposedPath = pathComposer(this.__relatedTarget, true);\n }\n // find the deepest node in relatedTarget composed path that is in the same root with the currentTarget\n return retarget(this.currentTarget, this.__relatedTargetComposedPath);\n },\n /**\n * @this {Event}\n */\n stopPropagation() {\n Event.prototype.stopPropagation.call(this);\n this.__propagationStopped = true;\n },\n /**\n * @this {Event}\n */\n stopImmediatePropagation() {\n Event.prototype.stopImmediatePropagation.call(this);\n this.__immediatePropagationStopped = true;\n this.__propagationStopped = true;\n }\n\n};\n\nfunction mixinComposedFlag(Base) {\n // NOTE: avoiding use of `class` here so that transpiled output does not\n // try to do `Base.call` with a dom construtor.\n let klazz = function(type, options) {\n let event = new Base(type, options);\n event.__composed = options && Boolean(options['composed']);\n return event;\n }\n // put constructor properties on subclass\n utils.mixin(klazz, Base);\n klazz.prototype = Base.prototype;\n return klazz;\n}\n\nlet nonBubblingEventsToRetarget = {\n 'focus': true,\n 'blur': true\n};\n\n\nfunction fireHandlers(event, node, phase) {\n let hs = node.__handlers && node.__handlers[event.type] &&\n node.__handlers[event.type][phase];\n if (hs) {\n for (let i = 0, fn; (fn = hs[i]); i++) {\n if (event.target === event.relatedTarget) {\n return;\n }\n fn.call(node, event);\n if (event.__immediatePropagationStopped) {\n return;\n }\n }\n }\n}\n\nfunction retargetNonBubblingEvent(e) {\n let path = e.composedPath();\n let node;\n // override `currentTarget` to let patched `target` calculate correctly\n Object.defineProperty(e, 'currentTarget', {\n get: function() {\n return node;\n },\n configurable: true\n });\n for (let i = path.length - 1; i >= 0; i--) {\n node = path[i];\n // capture phase fires all capture handlers\n fireHandlers(e, node, 'capture');\n if (e.__propagationStopped) {\n return;\n }\n }\n\n // set the event phase to `AT_TARGET` as in spec\n Object.defineProperty(e, 'eventPhase', {get() { return Event.AT_TARGET }});\n\n // the event only needs to be fired when owner roots change when iterating the event path\n // keep track of the last seen owner root\n let lastFiredRoot;\n for (let i = 0; i < path.length; i++) {\n node = path[i];\n if (i === 0 || (node.shadowRoot && node.shadowRoot === lastFiredRoot)) {\n fireHandlers(e, node, 'bubble');\n // don't bother with window, it doesn't have `getRootNode` and will be last in the path anyway\n if (node !== window) {\n lastFiredRoot = node.getRootNode();\n }\n if (e.__propagationStopped) {\n return;\n }\n }\n }\n}\n\nfunction listenerSettingsEqual(savedListener, node, type, capture, once, passive) {\n let {\n node: savedNode,\n type: savedType,\n capture: savedCapture,\n once: savedOnce,\n passive: savedPassive\n } = savedListener;\n return node === savedNode &&\n type === savedType &&\n capture === savedCapture &&\n once === savedOnce &&\n passive === savedPassive;\n}\n\nexport function findListener(wrappers, node, type, capture, once, passive) {\n for (let i = 0; i < wrappers.length; i++) {\n if (listenerSettingsEqual(wrappers[i], node, type, capture, once, passive)) {\n return i;\n }\n }\n return -1;\n}\n\n/**\n * @this {Event}\n */\nexport function addEventListener(type, fnOrObj, optionsOrCapture) {\n if (!fnOrObj) {\n return;\n }\n\n // The callback `fn` might be used for multiple nodes/events. Since we generate\n // a wrapper function, we need to keep track of it when we remove the listener.\n // It's more efficient to store the node/type/options information as Array in\n // `fn` itself rather than the node (we assume that the same callback is used\n // for few nodes at most, whereas a node will likely have many event listeners).\n // NOTE(valdrin) invoking external functions is costly, inline has better perf.\n let capture, once, passive;\n if (typeof optionsOrCapture === 'object') {\n capture = Boolean(optionsOrCapture.capture);\n once = Boolean(optionsOrCapture.once);\n passive = Boolean(optionsOrCapture.passive);\n } else {\n capture = Boolean(optionsOrCapture);\n once = false;\n passive = false;\n }\n // hack to let ShadyRoots have event listeners\n // event listener will be on host, but `currentTarget`\n // will be set to shadyroot for event listener\n // NOTE: if no `this`, we assume this method was called on window.\n let context = this || window;\n let target = (optionsOrCapture && optionsOrCapture.__shadyTarget) || context;\n\n if (fnOrObj.__eventWrappers) {\n // Stop if the wrapper function has already been created.\n if (findListener(fnOrObj.__eventWrappers, target, type, capture, once, passive) > -1) {\n return;\n }\n } else {\n fnOrObj.__eventWrappers = [];\n }\n\n /**\n * @this {HTMLElement}\n */\n const wrapperFn = function(e) {\n // Support `once` option.\n if (once) {\n this.removeEventListener(type, fnOrObj, optionsOrCapture);\n }\n if (!e['__target']) {\n patchEvent(e);\n }\n let lastCurrentTargetDesc;\n if (target !== this) {\n // replace `currentTarget` to make `target` and `relatedTarget` correct for inside the shadowroot\n lastCurrentTargetDesc = Object.getOwnPropertyDescriptor(e, 'currentTarget');\n Object.defineProperty(e, 'currentTarget', {get() { return target }, configurable: true});\n }\n // There are two critera that should stop events from firing on this node\n // 1. the event is not composed and the current node is not in the same root as the target\n // 2. when bubbling, if after retargeting, relatedTarget and target point to the same node\n if (e.composed || e.composedPath().indexOf(target) > -1) {\n if (e.target === e.relatedTarget) {\n if (e.eventPhase === Event.BUBBLING_PHASE) {\n e.stopImmediatePropagation();\n }\n return;\n }\n // prevent non-bubbling events from triggering bubbling handlers on shadowroot, but only if not in capture phase\n if (e.eventPhase !== Event.CAPTURING_PHASE && !e.bubbles && e.target !== target) {\n return;\n }\n let ret = (typeof fnOrObj === 'object' && fnOrObj.handleEvent) ?\n fnOrObj.handleEvent(e) :\n fnOrObj.call(target, e);\n if (target !== this) {\n // replace the \"correct\" `currentTarget`\n if (lastCurrentTargetDesc) {\n Object.defineProperty(e, 'currentTarget', lastCurrentTargetDesc);\n lastCurrentTargetDesc = null;\n } else {\n delete e['currentTarget'];\n }\n }\n return ret;\n }\n };\n // Store the wrapper information.\n fnOrObj.__eventWrappers.push({\n node: context,\n type: type,\n capture: capture,\n once: once,\n passive: passive,\n wrapperFn: wrapperFn\n });\n\n if (nonBubblingEventsToRetarget[type]) {\n context.__handlers = context.__handlers || {};\n context.__handlers[type] = context.__handlers[type] ||\n {'capture': [], 'bubble': []};\n context.__handlers[type][capture ? 'capture' : 'bubble'].push(wrapperFn);\n } else {\n let ael = context instanceof Window ? nativeMethods.windowAddEventListener :\n nativeMethods.addEventListener;\n ael.call(context, type, wrapperFn, optionsOrCapture);\n }\n}\n\n/**\n * @this {Event}\n */\nexport function removeEventListener(type, fnOrObj, optionsOrCapture) {\n if (!fnOrObj) {\n return;\n }\n\n // NOTE(valdrin) invoking external functions is costly, inline has better perf.\n let capture, once, passive;\n if (typeof optionsOrCapture === 'object') {\n capture = Boolean(optionsOrCapture.capture);\n once = Boolean(optionsOrCapture.once);\n passive = Boolean(optionsOrCapture.passive);\n } else {\n capture = Boolean(optionsOrCapture);\n once = false;\n passive = false;\n }\n // NOTE: if no `this`, we assume this method was called on window.\n let context = this || window;\n let target = (optionsOrCapture && optionsOrCapture.__shadyTarget) || context;\n // Search the wrapped function.\n let wrapperFn = undefined;\n if (fnOrObj.__eventWrappers) {\n let idx = findListener(fnOrObj.__eventWrappers, target, type, capture, once, passive);\n if (idx > -1) {\n wrapperFn = fnOrObj.__eventWrappers.splice(idx, 1)[0].wrapperFn;\n // Cleanup.\n if (!fnOrObj.__eventWrappers.length) {\n fnOrObj.__eventWrappers = undefined;\n }\n }\n }\n let rel = context instanceof Window ? nativeMethods.windowRemoveEventListener :\n nativeMethods.removeEventListener;\n rel.call(context, type, wrapperFn || fnOrObj, optionsOrCapture);\n if (wrapperFn && nonBubblingEventsToRetarget[type] &&\n context.__handlers && context.__handlers[type]) {\n const arr = context.__handlers[type][capture ? 'capture' : 'bubble'];\n const idx = arr.indexOf(wrapperFn);\n if (idx > -1) {\n arr.splice(idx, 1);\n }\n }\n}\n\nfunction activateFocusEventOverrides() {\n for (let ev in nonBubblingEventsToRetarget) {\n window.addEventListener(ev, function(e) {\n if (!e['__target']) {\n patchEvent(e);\n retargetNonBubblingEvent(e);\n }\n }, true);\n }\n}\n\nfunction patchEvent(event) {\n event['__target'] = event.target;\n event.__relatedTarget = event.relatedTarget;\n // patch event prototype if we can\n if (utils.settings.hasDescriptors) {\n utils.patchPrototype(event, eventMixin);\n // and fallback to patching instance\n } else {\n utils.extend(event, eventMixin);\n }\n}\n\nlet PatchedEvent = mixinComposedFlag(window.Event);\nlet PatchedCustomEvent = mixinComposedFlag(window.CustomEvent);\nlet PatchedMouseEvent = mixinComposedFlag(window.MouseEvent);\n\nexport function patchEvents() {\n window.Event = PatchedEvent;\n window.CustomEvent = PatchedCustomEvent;\n window.MouseEvent = PatchedMouseEvent;\n activateFocusEventOverrides();\n}\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport * as utils from './utils'\nimport {flush} from './flush'\nimport {dispatchEvent} from './native-methods'\nimport * as mutation from './logical-mutation'\nimport {ActiveElementAccessor, ShadowRootAccessor, patchAccessors} from './patch-accessors'\nimport {addEventListener, removeEventListener} from './patch-events'\nimport {attachShadow, ShadyRoot} from './attach-shadow'\n\nfunction getAssignedSlot(node) {\n mutation.renderRootNode(node);\n return node.__shady && node.__shady.assignedSlot || null;\n}\n\nlet windowMixin = {\n\n addEventListener: addEventListener,\n\n removeEventListener: removeEventListener\n};\n\nlet nodeMixin = {\n\n addEventListener: addEventListener,\n\n removeEventListener: removeEventListener,\n\n appendChild(node) {\n return mutation.insertBefore(this, node);\n },\n\n insertBefore(node, ref_node) {\n return mutation.insertBefore(this, node, ref_node);\n },\n\n removeChild(node) {\n return mutation.removeChild(this, node);\n },\n\n /**\n * @this {Node}\n */\n replaceChild(node, ref_node) {\n this.insertBefore(node, ref_node);\n this.removeChild(ref_node);\n return node;\n },\n\n /**\n * @this {Node}\n */\n cloneNode(deep) {\n return mutation.cloneNode(this, deep);\n },\n\n /**\n * @this {Node}\n */\n getRootNode(options) {\n return mutation.getRootNode(this, options);\n },\n\n /**\n * @this {Node}\n */\n get isConnected() {\n // Fast path for distributed nodes.\n const ownerDocument = this.ownerDocument;\n if (ownerDocument && ownerDocument.contains && ownerDocument.contains(this)) return true;\n const ownerDocumentElement = ownerDocument.documentElement;\n if (ownerDocumentElement && ownerDocumentElement.contains && ownerDocumentElement.contains(this)) return true;\n\n let node = this;\n while (node && !(node instanceof Document)) {\n node = node.parentNode || (node instanceof ShadyRoot ? /** @type {ShadowRoot} */(node).host : undefined);\n }\n return !!(node && node instanceof Document);\n },\n\n /**\n * @this {Node}\n */\n dispatchEvent(event) {\n flush();\n return dispatchEvent.call(this, event);\n }\n\n};\n\n// NOTE: For some reason `Text` redefines `assignedSlot`\nlet textMixin = {\n /**\n * @this {Text}\n */\n get assignedSlot() {\n return getAssignedSlot(this);\n }\n};\n\nlet fragmentMixin = {\n\n // TODO(sorvell): consider doing native QSA and filtering results.\n /**\n * @this {DocumentFragment}\n */\n querySelector(selector) {\n // match selector and halt on first result.\n let result = mutation.query(this, function(n) {\n return utils.matchesSelector(n, selector);\n }, function(n) {\n return Boolean(n);\n })[0];\n return result || null;\n },\n\n /**\n * @this {DocumentFragment}\n */\n querySelectorAll(selector) {\n return mutation.query(this, function(n) {\n return utils.matchesSelector(n, selector);\n });\n }\n\n};\n\nlet slotMixin = {\n\n /**\n * @this {HTMLSlotElement}\n */\n assignedNodes(options) {\n if (this.localName === 'slot') {\n mutation.renderRootNode(this);\n return this.__shady ?\n ((options && options.flatten ? this.__shady.distributedNodes :\n this.__shady.assignedNodes) || []) :\n [];\n }\n }\n\n};\n\nlet elementMixin = utils.extendAll({\n\n /**\n * @this {HTMLElement}\n */\n setAttribute(name, value) {\n mutation.setAttribute(this, name, value);\n },\n\n /**\n * @this {HTMLElement}\n */\n removeAttribute(name) {\n mutation.removeAttribute(this, name);\n },\n\n /**\n * @this {HTMLElement}\n */\n attachShadow(options) {\n return attachShadow(this, options);\n },\n\n /**\n * @this {HTMLElement}\n */\n get slot() {\n return this.getAttribute('slot');\n },\n\n /**\n * @this {HTMLElement}\n */\n set slot(value) {\n this.setAttribute('slot', value);\n },\n\n /**\n * @this {HTMLElement}\n */\n get assignedSlot() {\n return getAssignedSlot(this);\n }\n\n}, fragmentMixin, slotMixin);\n\nObject.defineProperties(elementMixin, ShadowRootAccessor);\n\nlet documentMixin = utils.extendAll({\n /**\n * @this {Document}\n */\n importNode(node, deep) {\n return mutation.importNode(node, deep);\n },\n\n /**\n * @this {Document}\n */\n getElementById(id) {\n return this.querySelector(`#${id}`);\n }\n\n}, fragmentMixin);\n\nObject.defineProperties(documentMixin, {\n '_activeElement': ActiveElementAccessor.activeElement\n});\n\nlet nativeBlur = HTMLElement.prototype.blur;\n\nlet htmlElementMixin = utils.extendAll({\n /**\n * @this {HTMLElement}\n */\n blur() {\n let root = this.shadowRoot;\n let shadowActive = root && root.activeElement;\n if (shadowActive) {\n shadowActive.blur();\n } else {\n nativeBlur.call(this);\n }\n }\n})\n\nfunction patchBuiltin(proto, obj) {\n let n$ = Object.getOwnPropertyNames(obj);\n for (let i=0; i < n$.length; i++) {\n let n = n$[i];\n let d = Object.getOwnPropertyDescriptor(obj, n);\n // NOTE: we prefer writing directly here because some browsers\n // have descriptors that are writable but not configurable (e.g.\n // `appendChild` on older browsers)\n if (d.value) {\n proto[n] = d.value;\n } else {\n Object.defineProperty(proto, n, d);\n }\n }\n}\n\n\n// Apply patches to builtins (e.g. Element.prototype). Some of these patches\n// can be done unconditionally (mostly methods like\n// `Element.prototype.appendChild`) and some can only be done when the browser\n// has proper descriptors on the builtin prototype\n// (e.g. `Element.prototype.firstChild`)`. When descriptors are not available,\n// elements are individually patched when needed (see e.g.\n// `patchInside/OutsideElementAccessors` in `patch-accessors.js`).\nexport function patchBuiltins() {\n let nativeHTMLElement =\n (window['customElements'] && window['customElements']['nativeHTMLElement']) ||\n HTMLElement;\n // These patches can always be done, for all supported browsers.\n patchBuiltin(window.Node.prototype, nodeMixin);\n patchBuiltin(window.Window.prototype, windowMixin);\n patchBuiltin(window.Text.prototype, textMixin);\n patchBuiltin(window.DocumentFragment.prototype, fragmentMixin);\n patchBuiltin(window.Element.prototype, elementMixin);\n patchBuiltin(window.Document.prototype, documentMixin);\n if (window.HTMLSlotElement) {\n patchBuiltin(window.HTMLSlotElement.prototype, slotMixin);\n }\n patchBuiltin(nativeHTMLElement.prototype, htmlElementMixin);\n // These patches can *only* be done\n // on browsers that have proper property descriptors on builtin prototypes.\n // This includes: IE11, Edge, Chrome >= 4?; Safari >= 10, Firefox\n // On older browsers (Chrome <= 4?, Safari 9), a per element patching\n // strategy is used for patching accessors.\n if (utils.settings.hasDescriptors) {\n patchAccessors(window.Node.prototype);\n patchAccessors(window.Text.prototype);\n patchAccessors(window.DocumentFragment.prototype);\n patchAccessors(window.Element.prototype);\n patchAccessors(nativeHTMLElement.prototype);\n patchAccessors(window.Document.prototype);\n if (window.HTMLSlotElement) {\n patchAccessors(window.HTMLSlotElement.prototype);\n }\n }\n}\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n/**\n * Patches elements that interacts with ShadyDOM\n * such that tree traversal and mutation apis act like they would under\n * ShadowDOM.\n *\n * This import enables seemless interaction with ShadyDOM powered\n * custom elements, enabling better interoperation with 3rd party code,\n * libraries, and frameworks that use DOM tree manipulation apis.\n */\n\n'use strict';\nimport * as utils from './utils'\nimport {flush, enqueue} from './flush'\nimport {observeChildren, unobserveChildren, filterMutations} from './observe-changes'\nimport * as nativeMethods from './native-methods'\nimport * as nativeTree from './native-tree'\nimport {patchBuiltins} from './patch-builtins'\nimport {patchEvents} from './patch-events'\nimport {ShadyRoot} from './attach-shadow'\n\nif (utils.settings.inUse) {\n let ShadyDOM = {\n // TODO(sorvell): remove when Polymer does not depend on this.\n 'inUse': utils.settings.inUse,\n // TODO(sorvell): remove when Polymer does not depend on this\n 'patch': (node) => node,\n 'isShadyRoot': utils.isShadyRoot,\n 'enqueue': enqueue,\n 'flush': flush,\n 'settings': utils.settings,\n 'filterMutations': filterMutations,\n 'observeChildren': observeChildren,\n 'unobserveChildren': unobserveChildren,\n 'nativeMethods': nativeMethods,\n 'nativeTree': nativeTree\n };\n\n window['ShadyDOM'] = ShadyDOM;\n\n // Apply patches to events...\n patchEvents();\n // Apply patches to builtins (e.g. Element.prototype) where applicable.\n patchBuiltins();\n\n window.ShadowRoot = ShadyRoot;\n}"]} \ No newline at end of file diff --git a/src/patch-events.js b/src/patch-events.js index 79d6efb..ab13a1b 100644 --- a/src/patch-events.js +++ b/src/patch-events.js @@ -294,7 +294,9 @@ export function addEventListener(type, fnOrObj, optionsOrCapture) { // hack to let ShadyRoots have event listeners // event listener will be on host, but `currentTarget` // will be set to shadyroot for event listener - let target = optionsOrCapture && optionsOrCapture.__shadyTarget || this; + // NOTE: if no `this`, we assume this method was called on window. + let context = this || window; + let target = (optionsOrCapture && optionsOrCapture.__shadyTarget) || context; if (fnOrObj.__eventWrappers) { // Stop if the wrapper function has already been created. @@ -353,7 +355,7 @@ export function addEventListener(type, fnOrObj, optionsOrCapture) { }; // Store the wrapper information. fnOrObj.__eventWrappers.push({ - node: this, + node: context, type: type, capture: capture, once: once, @@ -362,14 +364,14 @@ export function addEventListener(type, fnOrObj, optionsOrCapture) { }); if (nonBubblingEventsToRetarget[type]) { - this.__handlers = this.__handlers || {}; - this.__handlers[type] = this.__handlers[type] || + context.__handlers = context.__handlers || {}; + context.__handlers[type] = context.__handlers[type] || {'capture': [], 'bubble': []}; - this.__handlers[type][capture ? 'capture' : 'bubble'].push(wrapperFn); + context.__handlers[type][capture ? 'capture' : 'bubble'].push(wrapperFn); } else { - let ael = this instanceof Window ? nativeMethods.windowAddEventListener : + let ael = context instanceof Window ? nativeMethods.windowAddEventListener : nativeMethods.addEventListener; - ael.call(this, type, wrapperFn, optionsOrCapture); + ael.call(context, type, wrapperFn, optionsOrCapture); } } @@ -392,7 +394,9 @@ export function removeEventListener(type, fnOrObj, optionsOrCapture) { once = false; passive = false; } - let target = optionsOrCapture && optionsOrCapture.__shadyTarget || this; + // NOTE: if no `this`, we assume this method was called on window. + let context = this || window; + let target = (optionsOrCapture && optionsOrCapture.__shadyTarget) || context; // Search the wrapped function. let wrapperFn = undefined; if (fnOrObj.__eventWrappers) { @@ -405,12 +409,12 @@ export function removeEventListener(type, fnOrObj, optionsOrCapture) { } } } - let rel = this instanceof Window ? nativeMethods.windowRemoveEventListener : + let rel = context instanceof Window ? nativeMethods.windowRemoveEventListener : nativeMethods.removeEventListener; - rel.call(this, type, wrapperFn || fnOrObj, optionsOrCapture); + rel.call(context, type, wrapperFn || fnOrObj, optionsOrCapture); if (wrapperFn && nonBubblingEventsToRetarget[type] && - this.__handlers && this.__handlers[type]) { - const arr = this.__handlers[type][capture ? 'capture' : 'bubble']; + context.__handlers && context.__handlers[type]) { + const arr = context.__handlers[type][capture ? 'capture' : 'bubble']; const idx = arr.indexOf(wrapperFn); if (idx > -1) { arr.splice(idx, 1); diff --git a/tests/event-path.html b/tests/event-path.html index 99f654c..98364eb 100644 --- a/tests/event-path.html +++ b/tests/event-path.html @@ -313,6 +313,20 @@ el.parentNode.removeChild(el); }); + test('implicit window add/remove event listener', function() { + var el = createEnabledElement('x-event-scoped-window'); + var listener = function(e) { + el.windowListenerEvents = el.windowListenerEvents ? el.windowListenerEvents+1 : 1; + }; + addEventListener("composed", listener); + el.fireComposed(); + assert.equal(1, el.windowListenerEvents); + removeEventListener("composed", listener); + el.fireComposed(); + assert.equal(1, el.windowListenerEvents); + el.parentNode.removeChild(el); + }); + test('scoped event does not reach window', function() { var el = createEnabledElement('x-event-scoped-window'); el.fireScoped(); From c8178ebfdbfd61b53c3baef2245ca0d173751233 Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Mon, 24 Apr 2017 14:22:53 -0700 Subject: [PATCH 2/2] Simpler fix for #139. --- shadydom.min.js | 55 ++++++++++++++++++++++--------------------- shadydom.min.js.map | 2 +- src/patch-builtins.js | 8 +++++-- src/patch-events.js | 28 ++++++++++------------ 4 files changed, 47 insertions(+), 46 deletions(-) diff --git a/shadydom.min.js b/shadydom.min.js index 5d60e29..f57b24e 100644 --- a/shadydom.min.js +++ b/shadydom.min.js @@ -9,12 +9,12 @@ Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ 'use strict';function n(a,b){return{index:a,l:[],o:b}} -function aa(a,b,c,d){var e=0,k=0,g=0,f=0,h=Math.min(b-e,d-k);if(0==e&&0==k)a:{for(g=0;g]/g;function ja(a){switch(a){case "&":return"&";case "<":return"<";case ">":return">";case '"':return""";case "\u00a0":return" "}}function ka(a){for(var b={},c=0;c";break a;case Node.TEXT_NODE:f=f.data;f=h&&ma[h.localName]?f:f.replace(ia,ja);break a;case Node.COMMENT_NODE:f="\x3c!--"+f.data+"--\x3e";break a;default:throw window.console.error(f), +function H(a,b){"template"===a.localName&&(a=a.content);for(var c="",d=b?b(a):a.childNodes,e=0,h=d.length,g;e";break a;case Node.TEXT_NODE:f=f.data;f=k&&ma[k.localName]?f:f.replace(ia,ja);break a;case Node.COMMENT_NODE:f="\x3c!--"+f.data+"--\x3e";break a;default:throw window.console.error(f), Error("not implemented");}}c+=f}return c};var I={},J=document.createTreeWalker(document,NodeFilter.SHOW_ALL,null,!1),K=document.createTreeWalker(document,NodeFilter.SHOW_ELEMENT,null,!1);function na(a){var b=[];J.currentNode=a;for(a=J.firstChild();a;)b.push(a),a=J.nextSibling();return b}I.parentNode=function(a){J.currentNode=a;return J.parentNode()};I.firstChild=function(a){J.currentNode=a;return J.firstChild()};I.lastChild=function(a){J.currentNode=a;return J.lastChild()};I.previousSibling=function(a){J.currentNode=a;return J.previousSibling()}; I.nextSibling=function(a){J.currentNode=a;return J.nextSibling()};I.childNodes=na;I.parentElement=function(a){K.currentNode=a;return K.parentNode()};I.firstElementChild=function(a){K.currentNode=a;return K.firstChild()};I.lastElementChild=function(a){K.currentNode=a;return K.lastChild()};I.previousElementSibling=function(a){K.currentNode=a;return K.previousSibling()};I.nextElementSibling=function(a){K.currentNode=a;return K.nextSibling()}; I.children=function(a){var b=[];K.currentNode=a;for(a=K.firstChild();a;)b.push(a),a=K.nextSibling();return b};I.innerHTML=function(a){return H(a,function(a){return na(a)})};I.textContent=function(a){if(a.nodeType!==Node.ELEMENT_NODE)return a.nodeValue;a=document.createTreeWalker(a,NodeFilter.SHOW_TEXT,null,!1);for(var b="",c;c=a.nextNode();)b+=c.nodeValue;return b};var M=Object.getOwnPropertyDescriptor(Element.prototype,"innerHTML")||Object.getOwnPropertyDescriptor(HTMLElement.prototype,"innerHTML"),N=document.implementation.createHTMLDocument("inert").createElement("div"),O=Object.getOwnPropertyDescriptor(Document.prototype,"activeElement"),oa={parentElement:{get:function(){var a=this.__shady&&this.__shady.parentNode;a&&a.nodeType!==Node.ELEMENT_NODE&&(a=null);return void 0!==a?a:I.parentElement(this)},configurable:!0},parentNode:{get:function(){var a=this.__shady&& @@ -28,39 +28,40 @@ this.__shady.root||null},set:function(a){this.__shady=this.__shady||{};this.__sh function R(a,b,c){for(var d in b){var e=Object.getOwnPropertyDescriptor(a,d);e&&e.configurable||!e&&c?Object.defineProperty(a,d,b[d]):c&&console.warn("Could not define",d,"on",a)}}function S(a){R(a,oa);R(a,P);R(a,Q)}var qa=p.i?function(){}:function(a){a.__shady&&a.__shady.O||(a.__shady=a.__shady||{},a.__shady.O=!0,R(a,oa,!0))},ra=p.i?function(){}:function(a){a.__shady&&a.__shady.M||(a.__shady=a.__shady||{},a.__shady.M=!0,R(a,P,!0),R(a,pa,!0))};function sa(a,b,c){qa(a);c=c||null;a.__shady=a.__shady||{};b.__shady=b.__shady||{};c&&(c.__shady=c.__shady||{});a.__shady.previousSibling=c?c.__shady.previousSibling:b.lastChild;var d=a.__shady.previousSibling;d&&d.__shady&&(d.__shady.nextSibling=a);(d=a.__shady.nextSibling=c)&&d.__shady&&(d.__shady.previousSibling=a);a.__shady.parentNode=b;c?c===b.__shady.firstChild&&(b.__shady.firstChild=a):(b.__shady.lastChild=a,b.__shady.firstChild||(b.__shady.firstChild=a));b.__shady.childNodes=null} function T(a){if(!a.__shady||void 0===a.__shady.firstChild){a.__shady=a.__shady||{};a.__shady.firstChild=I.firstChild(a);a.__shady.lastChild=I.lastChild(a);ra(a);for(var b=a.__shady.childNodes=I.childNodes(a),c=0,d;c '123yyyy'\n//\n// With 1-edit updates, the shortest path would be just to update all seven\n// characters. With 2-edit updates, we delete 4, leave 3, and add 4. This\n// leaves the substring '123' intact.\nfunction calcEditDistances(current, currentStart, currentEnd,\n old, oldStart, oldEnd) {\n // \"Deletion\" columns\n let rowCount = oldEnd - oldStart + 1;\n let columnCount = currentEnd - currentStart + 1;\n let distances = new Array(rowCount);\n\n // \"Addition\" rows. Initialize null column.\n for (let i = 0; i < rowCount; i++) {\n distances[i] = new Array(columnCount);\n distances[i][0] = i;\n }\n\n // Initialize null row\n for (let j = 0; j < columnCount; j++)\n distances[0][j] = j;\n\n for (let i = 1; i < rowCount; i++) {\n for (let j = 1; j < columnCount; j++) {\n if (equals(current[currentStart + j - 1], old[oldStart + i - 1]))\n distances[i][j] = distances[i - 1][j - 1];\n else {\n let north = distances[i - 1][j] + 1;\n let west = distances[i][j - 1] + 1;\n distances[i][j] = north < west ? north : west;\n }\n }\n }\n\n return distances;\n}\n\n// This starts at the final weight, and walks \"backward\" by finding\n// the minimum previous weight recursively until the origin of the weight\n// matrix.\nfunction spliceOperationsFromEditDistances(distances) {\n let i = distances.length - 1;\n let j = distances[0].length - 1;\n let current = distances[i][j];\n let edits = [];\n while (i > 0 || j > 0) {\n if (i == 0) {\n edits.push(EDIT_ADD);\n j--;\n continue;\n }\n if (j == 0) {\n edits.push(EDIT_DELETE);\n i--;\n continue;\n }\n let northWest = distances[i - 1][j - 1];\n let west = distances[i - 1][j];\n let north = distances[i][j - 1];\n\n let min;\n if (west < north)\n min = west < northWest ? west : northWest;\n else\n min = north < northWest ? north : northWest;\n\n if (min == northWest) {\n if (northWest == current) {\n edits.push(EDIT_LEAVE);\n } else {\n edits.push(EDIT_UPDATE);\n current = northWest;\n }\n i--;\n j--;\n } else if (min == west) {\n edits.push(EDIT_DELETE);\n i--;\n current = west;\n } else {\n edits.push(EDIT_ADD);\n j--;\n current = north;\n }\n }\n\n edits.reverse();\n return edits;\n}\n\n/**\n * Splice Projection functions:\n *\n * A splice map is a representation of how a previous array of items\n * was transformed into a new array of items. Conceptually it is a list of\n * tuples of\n *\n * \n *\n * which are kept in ascending index order of. The tuple represents that at\n * the |index|, |removed| sequence of items were removed, and counting forward\n * from |index|, |addedCount| items were added.\n */\n\n/**\n * Lacking individual splice mutation information, the minimal set of\n * splices can be synthesized given the previous state and final state of an\n * array. The basic approach is to calculate the edit distance matrix and\n * choose the shortest path through it.\n *\n * Complexity: O(l * p)\n * l: The length of the current array\n * p: The length of the old array\n */\nfunction calcSplices(current, currentStart, currentEnd,\n old, oldStart, oldEnd) {\n let prefixCount = 0;\n let suffixCount = 0;\n let splice;\n\n let minLength = Math.min(currentEnd - currentStart, oldEnd - oldStart);\n if (currentStart == 0 && oldStart == 0)\n prefixCount = sharedPrefix(current, old, minLength);\n\n if (currentEnd == current.length && oldEnd == old.length)\n suffixCount = sharedSuffix(current, old, minLength - prefixCount);\n\n currentStart += prefixCount;\n oldStart += prefixCount;\n currentEnd -= suffixCount;\n oldEnd -= suffixCount;\n\n if (currentEnd - currentStart == 0 && oldEnd - oldStart == 0)\n return [];\n\n if (currentStart == currentEnd) {\n splice = newSplice(currentStart, [], 0);\n while (oldStart < oldEnd)\n splice.removed.push(old[oldStart++]);\n\n return [ splice ];\n } else if (oldStart == oldEnd)\n return [ newSplice(currentStart, [], currentEnd - currentStart) ];\n\n let ops = spliceOperationsFromEditDistances(\n calcEditDistances(current, currentStart, currentEnd,\n old, oldStart, oldEnd));\n\n splice = undefined;\n let splices = [];\n let index = currentStart;\n let oldIndex = oldStart;\n for (let i = 0; i < ops.length; i++) {\n switch(ops[i]) {\n case EDIT_LEAVE:\n if (splice) {\n splices.push(splice);\n splice = undefined;\n }\n\n index++;\n oldIndex++;\n break;\n case EDIT_UPDATE:\n if (!splice)\n splice = newSplice(index, [], 0);\n\n splice.addedCount++;\n index++;\n\n splice.removed.push(old[oldIndex]);\n oldIndex++;\n break;\n case EDIT_ADD:\n if (!splice)\n splice = newSplice(index, [], 0);\n\n splice.addedCount++;\n index++;\n break;\n case EDIT_DELETE:\n if (!splice)\n splice = newSplice(index, [], 0);\n\n splice.removed.push(old[oldIndex]);\n oldIndex++;\n break;\n }\n }\n\n if (splice) {\n splices.push(splice);\n }\n return splices;\n}\n\nfunction sharedPrefix(current, old, searchLength) {\n for (let i = 0; i < searchLength; i++)\n if (!equals(current[i], old[i]))\n return i;\n return searchLength;\n}\n\nfunction sharedSuffix(current, old, searchLength) {\n let index1 = current.length;\n let index2 = old.length;\n let count = 0;\n while (count < searchLength && equals(current[--index1], old[--index2]))\n count++;\n\n return count;\n}\n\nfunction equals(currentValue, previousValue) {\n return currentValue === previousValue;\n}\n\nexport function calculateSplices(current, previous) {\n return calcSplices(current, 0, current.length, previous, 0,\n previous.length);\n}\n\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nexport let settings = window['ShadyDOM'] || {};\n\nsettings.hasNativeShadowDOM = Boolean(Element.prototype.attachShadow && Node.prototype.getRootNode);\n\nlet desc = Object.getOwnPropertyDescriptor(Node.prototype, 'firstChild');\n\nsettings.hasDescriptors = Boolean(desc && desc.configurable && desc.get);\nsettings.inUse = settings['force'] || !settings.hasNativeShadowDOM;\n\nexport function isShadyRoot(obj) {\n return Boolean(obj.__localName === 'ShadyRoot');\n}\n\nexport function ownerShadyRootForNode(node) {\n let root = node.getRootNode();\n if (isShadyRoot(root)) {\n return root;\n }\n}\n\nlet p = Element.prototype;\nlet matches = p.matches || p.matchesSelector ||\n p.mozMatchesSelector || p.msMatchesSelector ||\n p.oMatchesSelector || p.webkitMatchesSelector;\n\nexport function matchesSelector(element, selector) {\n return matches.call(element, selector);\n}\n\nfunction copyOwnProperty(name, source, target) {\n let pd = Object.getOwnPropertyDescriptor(source, name);\n if (pd) {\n Object.defineProperty(target, name, pd);\n }\n}\n\nexport function extend(target, source) {\n if (target && source) {\n let n$ = Object.getOwnPropertyNames(source);\n for (let i=0, n; (i {\n while (queue.length) {\n // catch errors in user code...\n try {\n queue.shift()();\n } catch(e) {\n // enqueue another record and throw\n twiddle.textContent = content++;\n throw(e);\n }\n }\n}).observe(twiddle, {characterData: true});\n\n// use MutationObserver to get microtask async timing.\nexport function microtask(callback) {\n queue.push(callback);\n twiddle.textContent = content++;\n}","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport * as utils from './utils'\n\n// render enqueuer/flusher\nlet flushList = [];\nlet scheduled;\nexport function enqueue(callback) {\n if (!scheduled) {\n scheduled = true;\n utils.microtask(flush);\n }\n flushList.push(callback);\n}\n\nexport function flush() {\n scheduled = false;\n let didFlush = Boolean(flushList.length);\n while (flushList.length) {\n flushList.shift()();\n }\n return didFlush;\n}\n\nflush['list'] = flushList;","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\n// Cribbed from ShadowDOM polyfill\n// https://github.com/webcomponents/webcomponentsjs/blob/master/src/ShadowDOM/wrappers/HTMLElement.js#L28\n/////////////////////////////////////////////////////////////////////////////\n// innerHTML and outerHTML\n\n// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#escapingString\nlet escapeAttrRegExp = /[&\\u00A0\"]/g;\nlet escapeDataRegExp = /[&\\u00A0<>]/g;\n\nfunction escapeReplace(c) {\n switch (c) {\n case '&':\n return '&';\n case '<':\n return '<';\n case '>':\n return '>';\n case '\"':\n return '"';\n case '\\u00A0':\n return ' ';\n }\n}\n\nfunction escapeAttr(s) {\n return s.replace(escapeAttrRegExp, escapeReplace);\n}\n\nfunction escapeData(s) {\n return s.replace(escapeDataRegExp, escapeReplace);\n}\n\nfunction makeSet(arr) {\n let set = {};\n for (let i = 0; i < arr.length; i++) {\n set[arr[i]] = true;\n }\n return set;\n}\n\n// http://www.whatwg.org/specs/web-apps/current-work/#void-elements\nlet voidElements = makeSet([\n 'area',\n 'base',\n 'br',\n 'col',\n 'command',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'keygen',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr'\n]);\n\nlet plaintextParents = makeSet([\n 'style',\n 'script',\n 'xmp',\n 'iframe',\n 'noembed',\n 'noframes',\n 'plaintext',\n 'noscript'\n]);\n\n/**\n * @param {Node} node\n * @param {Node} parentNode\n * @param {Function=} callback\n */\nexport function getOuterHTML(node, parentNode, callback) {\n switch (node.nodeType) {\n case Node.ELEMENT_NODE: {\n let tagName = node.localName;\n let s = '<' + tagName;\n let attrs = node.attributes;\n for (let i = 0, attr; (attr = attrs[i]); i++) {\n s += ' ' + attr.name + '=\"' + escapeAttr(attr.value) + '\"';\n }\n s += '>';\n if (voidElements[tagName]) {\n return s;\n }\n return s + getInnerHTML(node, callback) + '';\n }\n case Node.TEXT_NODE: {\n let data = /** @type {Text} */ (node).data;\n if (parentNode && plaintextParents[parentNode.localName]) {\n return data;\n }\n return escapeData(data);\n }\n case Node.COMMENT_NODE: {\n return '';\n }\n default: {\n window.console.error(node);\n throw new Error('not implemented');\n }\n }\n}\n\n/**\n * @param {Node} node\n * @param {Function=} callback\n */\nexport function getInnerHTML(node, callback) {\n if (node.localName === 'template') {\n node = /** @type {HTMLTemplateElement} */ (node).content;\n }\n let s = '';\n let c$ = callback ? callback(node) : node.childNodes;\n for (let i=0, l=c$.length, child; (i childNodes(n));\n}\n\nexport function textContent(node) {\n if (node.nodeType !== Node.ELEMENT_NODE) {\n return node.nodeValue;\n }\n let textWalker = document.createTreeWalker(node, NodeFilter.SHOW_TEXT,\n null, false);\n let content = '', n;\n while ( (n = textWalker.nextNode()) ) {\n // TODO(sorvell): can't use textContent since we patch it on Node.prototype!\n // However, should probably patch it only on element.\n content += n.nodeValue;\n }\n return content;\n}","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport * as utils from './utils'\nimport {getInnerHTML} from './innerHTML'\nimport * as nativeTree from './native-tree'\n\nfunction clearNode(node) {\n while (node.firstChild) {\n node.removeChild(node.firstChild);\n }\n}\n\nconst nativeInnerHTMLDesc = /** @type {ObjectPropertyDescriptor} */(\n Object.getOwnPropertyDescriptor(Element.prototype, 'innerHTML') ||\n Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'innerHTML'));\n\nconst inertDoc = document.implementation.createHTMLDocument('inert');\nconst htmlContainer = inertDoc.createElement('div');\n\nconst nativeActiveElementDescriptor =\n /** @type {ObjectPropertyDescriptor} */(\n Object.getOwnPropertyDescriptor(Document.prototype, 'activeElement')\n );\nfunction getDocumentActiveElement() {\n if (nativeActiveElementDescriptor && nativeActiveElementDescriptor.get) {\n return nativeActiveElementDescriptor.get.call(document);\n } else if (!utils.settings.hasDescriptors) {\n return document.activeElement;\n }\n}\n\nfunction activeElementForNode(node) {\n let active = getDocumentActiveElement();\n // In IE11, activeElement might be an empty object if the document is\n // contained in an iframe.\n // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10998788/\n if (!active || !active.nodeType) {\n return null;\n }\n let isShadyRoot = !!(utils.isShadyRoot(node));\n if (node !== document) {\n // If this node isn't a document or shady root, then it doesn't have\n // an active element.\n if (!isShadyRoot) {\n return null;\n }\n // If this shady root's host is the active element or the active\n // element is not a descendant of the host (in the composed tree),\n // then it doesn't have an active element.\n if (node.host === active ||\n !node.host.contains(active)) {\n return null;\n }\n }\n // This node is either the document or a shady root of which the active\n // element is a (composed) descendant of its host; iterate upwards to\n // find the active element's most shallow host within it.\n let activeRoot = utils.ownerShadyRootForNode(active);\n while (activeRoot && activeRoot !== node) {\n active = activeRoot.host;\n activeRoot = utils.ownerShadyRootForNode(active);\n }\n if (node === document) {\n // This node is the document, so activeRoot should be null.\n return activeRoot ? null : active;\n } else {\n // This node is a non-document shady root, and it should be\n // activeRoot.\n return activeRoot === node ? active : null;\n }\n}\n\nlet OutsideAccessors = {\n\n parentElement: {\n /** @this {Node} */\n get() {\n let l = this.__shady && this.__shady.parentNode;\n if (l && l.nodeType !== Node.ELEMENT_NODE) {\n l = null;\n }\n return l !== undefined ? l : nativeTree.parentElement(this);\n },\n configurable: true\n },\n\n parentNode: {\n /** @this {Node} */\n get() {\n let l = this.__shady && this.__shady.parentNode;\n return l !== undefined ? l : nativeTree.parentNode(this);\n },\n configurable: true\n },\n\n nextSibling: {\n /** @this {Node} */\n get() {\n let l = this.__shady && this.__shady.nextSibling;\n return l !== undefined ? l : nativeTree.nextSibling(this);\n },\n configurable: true\n },\n\n previousSibling: {\n /** @this {Node} */\n get() {\n let l = this.__shady && this.__shady.previousSibling;\n return l !== undefined ? l : nativeTree.previousSibling(this);\n },\n configurable: true\n },\n\n className: {\n /**\n * @this {HTMLElement}\n */\n get() {\n return this.getAttribute('class') || '';\n },\n /**\n * @this {HTMLElement}\n */\n set(value) {\n this.setAttribute('class', value);\n },\n configurable: true\n },\n\n // fragment, element, document\n nextElementSibling: {\n /**\n * @this {HTMLElement}\n */\n get() {\n if (this.__shady && this.__shady.nextSibling !== undefined) {\n let n = this.nextSibling;\n while (n && n.nodeType !== Node.ELEMENT_NODE) {\n n = n.nextSibling;\n }\n return n;\n } else {\n return nativeTree.nextElementSibling(this);\n }\n },\n configurable: true\n },\n\n previousElementSibling: {\n /**\n * @this {HTMLElement}\n */\n get() {\n if (this.__shady && this.__shady.previousSibling !== undefined) {\n let n = this.previousSibling;\n while (n && n.nodeType !== Node.ELEMENT_NODE) {\n n = n.previousSibling;\n }\n return n;\n } else {\n return nativeTree.previousElementSibling(this);\n }\n },\n configurable: true\n }\n\n};\n\nlet InsideAccessors = {\n\n childNodes: {\n /**\n * @this {HTMLElement}\n */\n get() {\n let childNodes;\n if (this.__shady && this.__shady.firstChild !== undefined) {\n if (!this.__shady.childNodes) {\n this.__shady.childNodes = [];\n for (let n=this.firstChild; n; n=n.nextSibling) {\n this.__shady.childNodes.push(n);\n }\n }\n childNodes = this.__shady.childNodes;\n } else {\n childNodes = nativeTree.childNodes(this);\n }\n childNodes.item = function(index) {\n return childNodes[index];\n }\n return childNodes;\n },\n configurable: true\n },\n\n childElementCount: {\n /** @this {HTMLElement} */\n get() {\n return this.children.length;\n },\n configurable: true\n },\n\n firstChild: {\n /** @this {HTMLElement} */\n get() {\n let l = this.__shady && this.__shady.firstChild;\n return l !== undefined ? l : nativeTree.firstChild(this);\n },\n configurable: true\n },\n\n lastChild: {\n /** @this {HTMLElement} */\n get() {\n let l = this.__shady && this.__shady.lastChild;\n return l !== undefined ? l : nativeTree.lastChild(this);\n },\n configurable: true\n },\n\n textContent: {\n /**\n * @this {HTMLElement}\n */\n get() {\n if (this.__shady && this.__shady.firstChild !== undefined) {\n let tc = [];\n for (let i = 0, cn = this.childNodes, c; (c = cn[i]); i++) {\n if (c.nodeType !== Node.COMMENT_NODE) {\n tc.push(c.textContent);\n }\n }\n return tc.join('');\n } else {\n return nativeTree.textContent(this);\n }\n },\n /**\n * @this {HTMLElement}\n */\n set(text) {\n if (this.nodeType !== Node.ELEMENT_NODE) {\n // TODO(sorvell): can't do this if patch nodeValue.\n this.nodeValue = text;\n } else {\n clearNode(this);\n this.appendChild(document.createTextNode(text));\n }\n },\n configurable: true\n },\n\n // fragment, element, document\n firstElementChild: {\n /**\n * @this {HTMLElement}\n */\n get() {\n if (this.__shady && this.__shady.firstChild !== undefined) {\n let n = this.firstChild;\n while (n && n.nodeType !== Node.ELEMENT_NODE) {\n n = n.nextSibling;\n }\n return n;\n } else {\n return nativeTree.firstElementChild(this);\n }\n },\n configurable: true\n },\n\n lastElementChild: {\n /**\n * @this {HTMLElement}\n */\n get() {\n if (this.__shady && this.__shady.lastChild !== undefined) {\n let n = this.lastChild;\n while (n && n.nodeType !== Node.ELEMENT_NODE) {\n n = n.previousSibling;\n }\n return n;\n } else {\n return nativeTree.lastElementChild(this);\n }\n },\n configurable: true\n },\n\n children: {\n /**\n * @this {HTMLElement}\n */\n get() {\n let children;\n if (this.__shady && this.__shady.firstChild !== undefined) {\n children = Array.prototype.filter.call(this.childNodes, function(n) {\n return (n.nodeType === Node.ELEMENT_NODE);\n });\n } else {\n children = nativeTree.children(this);\n }\n children.item = function(index) {\n return children[index];\n }\n return children;\n },\n configurable: true\n },\n\n // element (HTMLElement on IE11)\n innerHTML: {\n /**\n * @this {HTMLElement}\n */\n get() {\n let content = this.localName === 'template' ?\n /** @type {HTMLTemplateElement} */(this).content : this;\n if (this.__shady && this.__shady.firstChild !== undefined) {\n return getInnerHTML(content);\n } else {\n return nativeTree.innerHTML(content);\n }\n },\n /**\n * @this {HTMLElement}\n */\n set(text) {\n let content = this.localName === 'template' ?\n /** @type {HTMLTemplateElement} */(this).content : this;\n clearNode(content);\n if (nativeInnerHTMLDesc && nativeInnerHTMLDesc.set) {\n nativeInnerHTMLDesc.set.call(htmlContainer, text);\n } else {\n htmlContainer.innerHTML = text;\n }\n while (htmlContainer.firstChild) {\n content.appendChild(htmlContainer.firstChild);\n }\n },\n configurable: true\n }\n\n};\n\n// Note: Can be patched on element prototype on all browsers.\n// Must be patched on instance on browsers that support native Shadow DOM\n// but do not have builtin accessors (old Chrome).\nexport let ShadowRootAccessor = {\n\n shadowRoot: {\n /**\n * @this {HTMLElement}\n */\n get() {\n return this.__shady && this.__shady.root || null;\n },\n /**\n * @this {HTMLElement}\n */\n set(value) {\n this.__shady = this.__shady || {};\n this.__shady.root = value;\n },\n configurable: true\n }\n};\n\n// Note: Can be patched on document prototype on browsers with builtin accessors.\n// Must be patched separately on simulated ShadowRoot.\n// Must be patched as `_activeElement` on browsers without builtin accessors.\nexport let ActiveElementAccessor = {\n\n activeElement: {\n /**\n * @this {HTMLElement}\n */\n get() {\n return activeElementForNode(this);\n },\n /**\n * @this {HTMLElement}\n */\n set() {},\n configurable: true\n }\n\n};\n\n// patch a group of descriptors on an object only if it exists or if the `force`\n// argument is true.\n/**\n * @param {!Object} obj\n * @param {!Object} descriptors\n * @param {boolean=} force\n */\nfunction patchAccessorGroup(obj, descriptors, force) {\n for (let p in descriptors) {\n let objDesc = Object.getOwnPropertyDescriptor(obj, p);\n if ((objDesc && objDesc.configurable) ||\n (!objDesc && force)) {\n Object.defineProperty(obj, p, descriptors[p]);\n } else if (force) {\n console.warn('Could not define', p, 'on', obj);\n }\n }\n}\n\n// patch dom accessors on proto where they exist\nexport function patchAccessors(proto) {\n patchAccessorGroup(proto, OutsideAccessors);\n patchAccessorGroup(proto, InsideAccessors);\n patchAccessorGroup(proto, ActiveElementAccessor);\n}\n\n// ensure element descriptors (IE/Edge don't have em)\nexport function patchShadowRootAccessors(proto) {\n patchAccessorGroup(proto, InsideAccessors, true);\n patchAccessorGroup(proto, ActiveElementAccessor, true);\n}\n\n// ensure an element has patched \"outside\" accessors; no-op when not needed\nexport let patchOutsideElementAccessors = utils.settings.hasDescriptors ?\n function() {} : function(element) {\n if (!(element.__shady && element.__shady.__outsideAccessors)) {\n element.__shady = element.__shady || {};\n element.__shady.__outsideAccessors = true;\n patchAccessorGroup(element, OutsideAccessors, true);\n }\n }\n\n// ensure an element has patched \"inside\" accessors; no-op when not needed\nexport let patchInsideElementAccessors = utils.settings.hasDescriptors ?\n function() {} : function(element) {\n if (!(element.__shady && element.__shady.__insideAccessors)) {\n element.__shady = element.__shady || {};\n element.__shady.__insideAccessors = true;\n patchAccessorGroup(element, InsideAccessors, true);\n patchAccessorGroup(element, ShadowRootAccessor, true);\n }\n }\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport {patchInsideElementAccessors, patchOutsideElementAccessors} from './patch-accessors'\nimport {firstChild, lastChild, childNodes} from './native-tree'\n\nexport function recordInsertBefore(node, container, ref_node) {\n patchInsideElementAccessors(container);\n container.__shady = container.__shady || {};\n if (container.__shady.firstChild !== undefined) {\n container.__shady.childNodes = null;\n }\n // handle document fragments\n if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n let c$ = node.childNodes;\n for (let i=0; i < c$.length; i++) {\n linkNode(c$[i], container, ref_node);\n }\n // cleanup logical dom in doc fragment.\n node.__shady = node.__shady || {};\n let resetTo = (node.__shady.firstChild !== undefined) ? null : undefined;\n node.__shady.firstChild = node.__shady.lastChild = resetTo;\n node.__shady.childNodes = resetTo;\n } else {\n linkNode(node, container, ref_node);\n }\n}\n\nfunction linkNode(node, container, ref_node) {\n patchOutsideElementAccessors(node);\n ref_node = ref_node || null;\n node.__shady = node.__shady || {};\n container.__shady = container.__shady || {};\n if (ref_node) {\n ref_node.__shady = ref_node.__shady || {};\n }\n // update ref_node.previousSibling <-> node\n node.__shady.previousSibling = ref_node ? ref_node.__shady.previousSibling :\n container.lastChild;\n let ps = node.__shady.previousSibling;\n if (ps && ps.__shady) {\n ps.__shady.nextSibling = node;\n }\n // update node <-> ref_node\n let ns = node.__shady.nextSibling = ref_node;\n if (ns && ns.__shady) {\n ns.__shady.previousSibling = node;\n }\n // update node <-> container\n node.__shady.parentNode = container;\n if (ref_node) {\n if (ref_node === container.__shady.firstChild) {\n container.__shady.firstChild = node;\n }\n } else {\n container.__shady.lastChild = node;\n if (!container.__shady.firstChild) {\n container.__shady.firstChild = node;\n }\n }\n // remove caching of childNodes\n container.__shady.childNodes = null;\n}\n\nexport function recordRemoveChild(node, container) {\n node.__shady = node.__shady || {};\n container.__shady = container.__shady || {};\n if (node === container.__shady.firstChild) {\n container.__shady.firstChild = node.__shady.nextSibling;\n }\n if (node === container.__shady.lastChild) {\n container.__shady.lastChild = node.__shady.previousSibling;\n }\n let p = node.__shady.previousSibling;\n let n = node.__shady.nextSibling;\n if (p) {\n p.__shady = p.__shady || {};\n p.__shady.nextSibling = n;\n }\n if (n) {\n n.__shady = n.__shady || {};\n n.__shady.previousSibling = p;\n }\n // When an element is removed, logical data is no longer tracked.\n // Explicitly set `undefined` here to indicate this. This is disginguished\n // from `null` which is set if info is null.\n node.__shady.parentNode = node.__shady.previousSibling =\n node.__shady.nextSibling = undefined;\n if (container.__shady.childNodes !== undefined) {\n // remove caching of childNodes\n container.__shady.childNodes = null;\n }\n}\n\nexport let recordChildNodes = function(node) {\n if (!node.__shady || node.__shady.firstChild === undefined) {\n node.__shady = node.__shady || {};\n node.__shady.firstChild = firstChild(node);\n node.__shady.lastChild = lastChild(node);\n patchInsideElementAccessors(node);\n let c$ = node.__shady.childNodes = childNodes(node);\n for (let i=0, n; (i host\n host.shadowRoot = this;\n this.host = host;\n // state flags\n this._renderPending = false;\n this._hasRendered = false;\n this._changePending = false;\n this._distributor = new Distributor(this);\n this.update();\n}\n\n\n// async render\nShadyRoot.prototype.update = function() {\n if (!this._renderPending) {\n this._renderPending = true;\n enqueue(() => this.render());\n }\n}\n\n// returns the oldest renderPending ancestor root.\nShadyRoot.prototype._getRenderRoot = function() {\n let renderRoot = this;\n let root = this;\n while (root) {\n if (root._renderPending) {\n renderRoot = root;\n }\n root = root._rendererForHost();\n }\n return renderRoot;\n}\n\n// Returns the shadyRoot `this.host` if `this.host`\n// has children that require distribution.\nShadyRoot.prototype._rendererForHost = function() {\n let root = this.host.getRootNode();\n if (utils.isShadyRoot(root)) {\n let c$ = this.host.childNodes;\n for (let i=0, c; i < c$.length; i++) {\n c = c$[i];\n if (this._distributor.isInsertionPoint(c)) {\n return root;\n }\n }\n }\n}\n\nShadyRoot.prototype.render = function() {\n if (this._renderPending) {\n this._getRenderRoot()['_render']();\n }\n}\n\n// NOTE: avoid renaming to ease testability.\nShadyRoot.prototype['_render'] = function() {\n this._renderPending = false;\n this._changePending = false;\n if (!this._skipUpdateInsertionPoints) {\n this.updateInsertionPoints();\n } else if (!this._hasRendered) {\n this.__insertionPoints = [];\n }\n this._skipUpdateInsertionPoints = false;\n // TODO(sorvell): can add a first render optimization here\n // to use if there are no insertion points\n // 1. clear host node of composed children\n // 2. appendChild the shadowRoot itself or (more robust) its logical children\n // NOTE: this didn't seem worth it in perf testing\n // but not ready to delete this info.\n // logical\n this.distribute();\n // physical\n this.compose();\n this._hasRendered = true;\n}\n\nShadyRoot.prototype.forceRender = function() {\n this._renderPending = true;\n this.render();\n}\n\nShadyRoot.prototype.distribute = function() {\n let dirtyRoots = this._distributor.distribute();\n for (let i=0; i children but since this case is assumed to be exceedingly\n // rare, we avoid the cost and will address with some specific api\n // when the need arises. For now, the user must call\n // distributeContent(true), which updates insertion points manually\n // and forces distribution.\n let insertionPointTag = ownerRoot && ownerRoot.getInsertionPointTag() || '';\n let fragContent = (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) &&\n !node['__noInsertionPoint'] &&\n insertionPointTag && node.querySelector(insertionPointTag);\n let wrappedContent = fragContent &&\n (fragContent.parentNode.nodeType !==\n Node.DOCUMENT_FRAGMENT_NODE);\n let hasContent = fragContent || (node.localName === insertionPointTag);\n // There are 3 possible cases where a distribution may need to occur:\n // 1. being inserted (the host of the shady root where\n // content is inserted needs distribution)\n // 2. children being inserted into parent with a shady root (parent\n // needs distribution)\n // 3. container is an insertionPoint\n if (hasContent || (container.localName === insertionPointTag) || ipAdded) {\n if (ownerRoot) {\n // note, insertion point list update is handled after node\n // mutations are complete\n updateRootViaContentChange(ownerRoot);\n }\n }\n let needsDist = _nodeNeedsDistribution(container);\n if (needsDist) {\n let root = container.__shady && container.__shady.root;\n updateRootViaContentChange(root);\n }\n // Return true when distribution will fully handle the composition\n // Note that if a content was being inserted that was wrapped by a node,\n // and the parent does not need distribution, return false to allow\n // the nodes to be added directly, after which children may be\n // distributed and composed into the wrapping node(s)\n return needsDist || (hasContent && !wrappedContent);\n}\n\n/* note: parent argument is required since node may have an out\nof date parent at this point; returns true if a is being added */\nfunction _maybeAddInsertionPoint(node, parent, root) {\n let added;\n let insertionPointTag = root.getInsertionPointTag();\n if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE &&\n !node['__noInsertionPoint']) {\n let c$ = node.querySelectorAll(insertionPointTag);\n for (let i=0, n, np, na; (i (host of container needs distribution)\n/**\n * @param {Node} parent\n * @param {Node} node\n * @param {Node=} ref_node\n */\nexport function insertBefore(parent, node, ref_node) {\n if (ref_node) {\n let p = ref_node.__shady && ref_node.__shady.parentNode;\n if ((p !== undefined && p !== parent) ||\n (p === undefined && parentNode(ref_node) !== parent)) {\n throw Error(`Failed to execute 'insertBefore' on 'Node': The node ` +\n `before which the new node is to be inserted is not a child of this node.`);\n }\n }\n if (ref_node === node) {\n return node;\n }\n // remove node from its current position iff it's in a tree.\n if (node.nodeType !== Node.DOCUMENT_FRAGMENT_NODE) {\n let parent = node.__shady && node.__shady.parentNode;\n removeNodeFromParent(node, parent);\n }\n if (!addNode(parent, node, ref_node)) {\n if (ref_node) {\n // if ref_node is an insertion point replace with first distributed node\n let root = utils.ownerShadyRootForNode(ref_node);\n if (root) {\n ref_node = ref_node.localName === root.getInsertionPointTag() ?\n firstComposedNode(/** @type {!HTMLSlotElement} */(ref_node)) : ref_node;\n }\n }\n // if adding to a shadyRoot, add to host instead\n let container = utils.isShadyRoot(parent) ? /** @type {ShadowRoot} */(parent).host : parent;\n if (ref_node) {\n nativeMethods.insertBefore.call(container, node, ref_node);\n } else {\n nativeMethods.appendChild.call(container, node);\n }\n }\n _scheduleObserver(parent, node);\n return node;\n}\n\n/**\n Removes the given `node` from the element's `lightChildren`.\n This method also performs dom composition.\n*/\nexport function removeChild(parent, node) {\n if (node.parentNode !== parent) {\n throw Error('The node to be removed is not a child of this node: ' +\n node);\n }\n if (!removeNode(node)) {\n // if removing from a shadyRoot, remove form host instead\n let container = utils.isShadyRoot(parent) ?\n parent.host :\n parent;\n // not guaranteed to physically be in container; e.g.\n // undistributed nodes.\n let nativeParent = parentNode(node);\n if (container === nativeParent) {\n nativeMethods.removeChild.call(container, node);\n }\n }\n _scheduleObserver(parent, null, node);\n return node;\n}\n\nexport function cloneNode(node, deep) {\n if (node.localName == 'template') {\n return nativeMethods.cloneNode.call(node, deep);\n } else {\n let n = nativeMethods.cloneNode.call(node, false);\n if (deep) {\n let c$ = node.childNodes;\n for (let i=0, nc; i < c$.length; i++) {\n nc = c$[i].cloneNode(true);\n n.appendChild(nc);\n }\n }\n return n;\n }\n}\n\n// note: Though not technically correct, we fast path `importNode`\n// when called on a node not owned by the main document.\n// This allows, for example, elements that cannot\n// contain custom elements and are therefore not likely to contain shadowRoots\n// to cloned natively. This is a fairly significant performance win.\nexport function importNode(node, deep) {\n if (node.ownerDocument !== document) {\n return nativeMethods.importNode.call(document, node, deep);\n }\n let n = nativeMethods.importNode.call(document, node, false);\n if (deep) {\n let c$ = node.childNodes;\n for (let i=0, nc; i < c$.length; i++) {\n nc = importNode(c$[i], true);\n n.appendChild(nc);\n }\n }\n return n;\n}\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport * as utils from './utils'\n\nclass AsyncObserver {\n\n constructor() {\n this._scheduled = false;\n this.addedNodes = [];\n this.removedNodes = [];\n this.callbacks = new Set();\n }\n\n schedule() {\n if (!this._scheduled) {\n this._scheduled = true;\n utils.microtask(() => {\n this.flush();\n });\n }\n }\n\n flush() {\n if (this._scheduled) {\n this._scheduled = false;\n let mutations = this.takeRecords();\n if (mutations.length) {\n this.callbacks.forEach(function(cb) {\n cb(mutations);\n });\n }\n }\n }\n\n takeRecords() {\n if (this.addedNodes.length || this.removedNodes.length) {\n let mutations = [{\n addedNodes: this.addedNodes,\n removedNodes: this.removedNodes\n }];\n this.addedNodes = [];\n this.removedNodes = [];\n return mutations;\n }\n return [];\n }\n\n}\n\n// TODO(sorvell): consider instead polyfilling MutationObserver\n// directly so that users do not have to fork their code.\n// Supporting the entire api may be challenging: e.g. filtering out\n// removed nodes in the wrong scope and seeing non-distributing\n// subtree child mutations.\nexport let observeChildren = function(node, callback) {\n node.__shady = node.__shady || {};\n if (!node.__shady.observer) {\n node.__shady.observer = new AsyncObserver();\n }\n node.__shady.observer.callbacks.add(callback);\n let observer = node.__shady.observer;\n return {\n _callback: callback,\n _observer: observer,\n _node: node,\n takeRecords() {\n return observer.takeRecords()\n }\n };\n}\n\nexport let unobserveChildren = function(handle) {\n let observer = handle && handle._observer;\n if (observer) {\n observer.callbacks.delete(handle._callback);\n if (!observer.callbacks.size) {\n handle._node.__shady.observer = null;\n }\n }\n}\n\nexport function filterMutations(mutations, target) {\n /** @const {Node} */\n const targetRootNode = target.getRootNode();\n return mutations.map(function(mutation) {\n /** @const {boolean} */\n const mutationInScope = (targetRootNode === mutation.target.getRootNode());\n if (mutationInScope && mutation.addedNodes) {\n let nodes = Array.from(mutation.addedNodes).filter(function(n) {\n return (targetRootNode === n.getRootNode());\n });\n if (nodes.length) {\n mutation = Object.create(mutation);\n Object.defineProperty(mutation, 'addedNodes', {\n value: nodes,\n configurable: true\n });\n return mutation;\n }\n } else if (mutationInScope) {\n return mutation;\n }\n }).filter(function(m) { return m});\n}","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport * as utils from './utils'\nimport * as nativeMethods from './native-methods'\n\n// https://github.com/w3c/webcomponents/issues/513#issuecomment-224183937\nlet alwaysComposed = {\n 'blur': true,\n 'focus': true,\n 'focusin': true,\n 'focusout': true,\n 'click': true,\n 'dblclick': true,\n 'mousedown': true,\n 'mouseenter': true,\n 'mouseleave': true,\n 'mousemove': true,\n 'mouseout': true,\n 'mouseover': true,\n 'mouseup': true,\n 'wheel': true,\n 'beforeinput': true,\n 'input': true,\n 'keydown': true,\n 'keyup': true,\n 'compositionstart': true,\n 'compositionupdate': true,\n 'compositionend': true,\n 'touchstart': true,\n 'touchend': true,\n 'touchmove': true,\n 'touchcancel': true,\n 'pointerover': true,\n 'pointerenter': true,\n 'pointerdown': true,\n 'pointermove': true,\n 'pointerup': true,\n 'pointercancel': true,\n 'pointerout': true,\n 'pointerleave': true,\n 'gotpointercapture': true,\n 'lostpointercapture': true,\n 'dragstart': true,\n 'drag': true,\n 'dragenter': true,\n 'dragleave': true,\n 'dragover': true,\n 'drop': true,\n 'dragend': true,\n 'DOMActivate': true,\n 'DOMFocusIn': true,\n 'DOMFocusOut': true,\n 'keypress': true\n};\n\nfunction pathComposer(startNode, composed) {\n let composedPath = [];\n let current = startNode;\n let startRoot = startNode === window ? window : startNode.getRootNode();\n while (current) {\n composedPath.push(current);\n if (current.assignedSlot) {\n current = current.assignedSlot;\n } else if (current.nodeType === Node.DOCUMENT_FRAGMENT_NODE && current.host && (composed || current !== startRoot)) {\n current = current.host;\n } else {\n current = current.parentNode;\n }\n }\n // event composedPath includes window when startNode's ownerRoot is document\n if (composedPath[composedPath.length - 1] === document) {\n composedPath.push(window);\n }\n return composedPath;\n}\n\nfunction retarget(refNode, path) {\n if (!utils.isShadyRoot) {\n return refNode;\n }\n // If ANCESTOR's root is not a shadow root or ANCESTOR's root is BASE's\n // shadow-including inclusive ancestor, return ANCESTOR.\n let refNodePath = pathComposer(refNode, true);\n let p$ = path;\n for (let i=0, ancestor, lastRoot, root, rootIdx; i < p$.length; i++) {\n ancestor = p$[i];\n root = ancestor === window ? window : ancestor.getRootNode();\n if (root !== lastRoot) {\n rootIdx = refNodePath.indexOf(root);\n lastRoot = root;\n }\n if (!utils.isShadyRoot(root) || rootIdx > -1) {\n return ancestor;\n }\n }\n}\n\nlet eventMixin = {\n\n /**\n * @this {Event}\n */\n get composed() {\n // isTrusted may not exist in this browser, so just check if isTrusted is explicitly false\n if (this.isTrusted !== false && this.__composed === undefined) {\n this.__composed = alwaysComposed[this.type];\n }\n return this.__composed || false;\n },\n\n /**\n * @this {Event}\n */\n composedPath() {\n if (!this.__composedPath) {\n this.__composedPath = pathComposer(this['__target'], this.composed);\n }\n return this.__composedPath;\n },\n\n /**\n * @this {Event}\n */\n get target() {\n return retarget(this.currentTarget, this.composedPath());\n },\n\n // http://w3c.github.io/webcomponents/spec/shadow/#event-relatedtarget-retargeting\n /**\n * @this {Event}\n */\n get relatedTarget() {\n if (!this.__relatedTarget) {\n return null;\n }\n if (!this.__relatedTargetComposedPath) {\n this.__relatedTargetComposedPath = pathComposer(this.__relatedTarget, true);\n }\n // find the deepest node in relatedTarget composed path that is in the same root with the currentTarget\n return retarget(this.currentTarget, this.__relatedTargetComposedPath);\n },\n /**\n * @this {Event}\n */\n stopPropagation() {\n Event.prototype.stopPropagation.call(this);\n this.__propagationStopped = true;\n },\n /**\n * @this {Event}\n */\n stopImmediatePropagation() {\n Event.prototype.stopImmediatePropagation.call(this);\n this.__immediatePropagationStopped = true;\n this.__propagationStopped = true;\n }\n\n};\n\nfunction mixinComposedFlag(Base) {\n // NOTE: avoiding use of `class` here so that transpiled output does not\n // try to do `Base.call` with a dom construtor.\n let klazz = function(type, options) {\n let event = new Base(type, options);\n event.__composed = options && Boolean(options['composed']);\n return event;\n }\n // put constructor properties on subclass\n utils.mixin(klazz, Base);\n klazz.prototype = Base.prototype;\n return klazz;\n}\n\nlet nonBubblingEventsToRetarget = {\n 'focus': true,\n 'blur': true\n};\n\n\nfunction fireHandlers(event, node, phase) {\n let hs = node.__handlers && node.__handlers[event.type] &&\n node.__handlers[event.type][phase];\n if (hs) {\n for (let i = 0, fn; (fn = hs[i]); i++) {\n if (event.target === event.relatedTarget) {\n return;\n }\n fn.call(node, event);\n if (event.__immediatePropagationStopped) {\n return;\n }\n }\n }\n}\n\nfunction retargetNonBubblingEvent(e) {\n let path = e.composedPath();\n let node;\n // override `currentTarget` to let patched `target` calculate correctly\n Object.defineProperty(e, 'currentTarget', {\n get: function() {\n return node;\n },\n configurable: true\n });\n for (let i = path.length - 1; i >= 0; i--) {\n node = path[i];\n // capture phase fires all capture handlers\n fireHandlers(e, node, 'capture');\n if (e.__propagationStopped) {\n return;\n }\n }\n\n // set the event phase to `AT_TARGET` as in spec\n Object.defineProperty(e, 'eventPhase', {get() { return Event.AT_TARGET }});\n\n // the event only needs to be fired when owner roots change when iterating the event path\n // keep track of the last seen owner root\n let lastFiredRoot;\n for (let i = 0; i < path.length; i++) {\n node = path[i];\n if (i === 0 || (node.shadowRoot && node.shadowRoot === lastFiredRoot)) {\n fireHandlers(e, node, 'bubble');\n // don't bother with window, it doesn't have `getRootNode` and will be last in the path anyway\n if (node !== window) {\n lastFiredRoot = node.getRootNode();\n }\n if (e.__propagationStopped) {\n return;\n }\n }\n }\n}\n\nfunction listenerSettingsEqual(savedListener, node, type, capture, once, passive) {\n let {\n node: savedNode,\n type: savedType,\n capture: savedCapture,\n once: savedOnce,\n passive: savedPassive\n } = savedListener;\n return node === savedNode &&\n type === savedType &&\n capture === savedCapture &&\n once === savedOnce &&\n passive === savedPassive;\n}\n\nexport function findListener(wrappers, node, type, capture, once, passive) {\n for (let i = 0; i < wrappers.length; i++) {\n if (listenerSettingsEqual(wrappers[i], node, type, capture, once, passive)) {\n return i;\n }\n }\n return -1;\n}\n\n/**\n * @this {Event}\n */\nexport function addEventListener(type, fnOrObj, optionsOrCapture) {\n if (!fnOrObj) {\n return;\n }\n\n // The callback `fn` might be used for multiple nodes/events. Since we generate\n // a wrapper function, we need to keep track of it when we remove the listener.\n // It's more efficient to store the node/type/options information as Array in\n // `fn` itself rather than the node (we assume that the same callback is used\n // for few nodes at most, whereas a node will likely have many event listeners).\n // NOTE(valdrin) invoking external functions is costly, inline has better perf.\n let capture, once, passive;\n if (typeof optionsOrCapture === 'object') {\n capture = Boolean(optionsOrCapture.capture);\n once = Boolean(optionsOrCapture.once);\n passive = Boolean(optionsOrCapture.passive);\n } else {\n capture = Boolean(optionsOrCapture);\n once = false;\n passive = false;\n }\n // hack to let ShadyRoots have event listeners\n // event listener will be on host, but `currentTarget`\n // will be set to shadyroot for event listener\n // NOTE: if no `this`, we assume this method was called on window.\n let context = this || window;\n let target = (optionsOrCapture && optionsOrCapture.__shadyTarget) || context;\n\n if (fnOrObj.__eventWrappers) {\n // Stop if the wrapper function has already been created.\n if (findListener(fnOrObj.__eventWrappers, target, type, capture, once, passive) > -1) {\n return;\n }\n } else {\n fnOrObj.__eventWrappers = [];\n }\n\n /**\n * @this {HTMLElement}\n */\n const wrapperFn = function(e) {\n // Support `once` option.\n if (once) {\n this.removeEventListener(type, fnOrObj, optionsOrCapture);\n }\n if (!e['__target']) {\n patchEvent(e);\n }\n let lastCurrentTargetDesc;\n if (target !== this) {\n // replace `currentTarget` to make `target` and `relatedTarget` correct for inside the shadowroot\n lastCurrentTargetDesc = Object.getOwnPropertyDescriptor(e, 'currentTarget');\n Object.defineProperty(e, 'currentTarget', {get() { return target }, configurable: true});\n }\n // There are two critera that should stop events from firing on this node\n // 1. the event is not composed and the current node is not in the same root as the target\n // 2. when bubbling, if after retargeting, relatedTarget and target point to the same node\n if (e.composed || e.composedPath().indexOf(target) > -1) {\n if (e.target === e.relatedTarget) {\n if (e.eventPhase === Event.BUBBLING_PHASE) {\n e.stopImmediatePropagation();\n }\n return;\n }\n // prevent non-bubbling events from triggering bubbling handlers on shadowroot, but only if not in capture phase\n if (e.eventPhase !== Event.CAPTURING_PHASE && !e.bubbles && e.target !== target) {\n return;\n }\n let ret = (typeof fnOrObj === 'object' && fnOrObj.handleEvent) ?\n fnOrObj.handleEvent(e) :\n fnOrObj.call(target, e);\n if (target !== this) {\n // replace the \"correct\" `currentTarget`\n if (lastCurrentTargetDesc) {\n Object.defineProperty(e, 'currentTarget', lastCurrentTargetDesc);\n lastCurrentTargetDesc = null;\n } else {\n delete e['currentTarget'];\n }\n }\n return ret;\n }\n };\n // Store the wrapper information.\n fnOrObj.__eventWrappers.push({\n node: context,\n type: type,\n capture: capture,\n once: once,\n passive: passive,\n wrapperFn: wrapperFn\n });\n\n if (nonBubblingEventsToRetarget[type]) {\n context.__handlers = context.__handlers || {};\n context.__handlers[type] = context.__handlers[type] ||\n {'capture': [], 'bubble': []};\n context.__handlers[type][capture ? 'capture' : 'bubble'].push(wrapperFn);\n } else {\n let ael = context instanceof Window ? nativeMethods.windowAddEventListener :\n nativeMethods.addEventListener;\n ael.call(context, type, wrapperFn, optionsOrCapture);\n }\n}\n\n/**\n * @this {Event}\n */\nexport function removeEventListener(type, fnOrObj, optionsOrCapture) {\n if (!fnOrObj) {\n return;\n }\n\n // NOTE(valdrin) invoking external functions is costly, inline has better perf.\n let capture, once, passive;\n if (typeof optionsOrCapture === 'object') {\n capture = Boolean(optionsOrCapture.capture);\n once = Boolean(optionsOrCapture.once);\n passive = Boolean(optionsOrCapture.passive);\n } else {\n capture = Boolean(optionsOrCapture);\n once = false;\n passive = false;\n }\n // NOTE: if no `this`, we assume this method was called on window.\n let context = this || window;\n let target = (optionsOrCapture && optionsOrCapture.__shadyTarget) || context;\n // Search the wrapped function.\n let wrapperFn = undefined;\n if (fnOrObj.__eventWrappers) {\n let idx = findListener(fnOrObj.__eventWrappers, target, type, capture, once, passive);\n if (idx > -1) {\n wrapperFn = fnOrObj.__eventWrappers.splice(idx, 1)[0].wrapperFn;\n // Cleanup.\n if (!fnOrObj.__eventWrappers.length) {\n fnOrObj.__eventWrappers = undefined;\n }\n }\n }\n let rel = context instanceof Window ? nativeMethods.windowRemoveEventListener :\n nativeMethods.removeEventListener;\n rel.call(context, type, wrapperFn || fnOrObj, optionsOrCapture);\n if (wrapperFn && nonBubblingEventsToRetarget[type] &&\n context.__handlers && context.__handlers[type]) {\n const arr = context.__handlers[type][capture ? 'capture' : 'bubble'];\n const idx = arr.indexOf(wrapperFn);\n if (idx > -1) {\n arr.splice(idx, 1);\n }\n }\n}\n\nfunction activateFocusEventOverrides() {\n for (let ev in nonBubblingEventsToRetarget) {\n window.addEventListener(ev, function(e) {\n if (!e['__target']) {\n patchEvent(e);\n retargetNonBubblingEvent(e);\n }\n }, true);\n }\n}\n\nfunction patchEvent(event) {\n event['__target'] = event.target;\n event.__relatedTarget = event.relatedTarget;\n // patch event prototype if we can\n if (utils.settings.hasDescriptors) {\n utils.patchPrototype(event, eventMixin);\n // and fallback to patching instance\n } else {\n utils.extend(event, eventMixin);\n }\n}\n\nlet PatchedEvent = mixinComposedFlag(window.Event);\nlet PatchedCustomEvent = mixinComposedFlag(window.CustomEvent);\nlet PatchedMouseEvent = mixinComposedFlag(window.MouseEvent);\n\nexport function patchEvents() {\n window.Event = PatchedEvent;\n window.CustomEvent = PatchedCustomEvent;\n window.MouseEvent = PatchedMouseEvent;\n activateFocusEventOverrides();\n}\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport * as utils from './utils'\nimport {flush} from './flush'\nimport {dispatchEvent} from './native-methods'\nimport * as mutation from './logical-mutation'\nimport {ActiveElementAccessor, ShadowRootAccessor, patchAccessors} from './patch-accessors'\nimport {addEventListener, removeEventListener} from './patch-events'\nimport {attachShadow, ShadyRoot} from './attach-shadow'\n\nfunction getAssignedSlot(node) {\n mutation.renderRootNode(node);\n return node.__shady && node.__shady.assignedSlot || null;\n}\n\nlet windowMixin = {\n\n addEventListener: addEventListener,\n\n removeEventListener: removeEventListener\n};\n\nlet nodeMixin = {\n\n addEventListener: addEventListener,\n\n removeEventListener: removeEventListener,\n\n appendChild(node) {\n return mutation.insertBefore(this, node);\n },\n\n insertBefore(node, ref_node) {\n return mutation.insertBefore(this, node, ref_node);\n },\n\n removeChild(node) {\n return mutation.removeChild(this, node);\n },\n\n /**\n * @this {Node}\n */\n replaceChild(node, ref_node) {\n this.insertBefore(node, ref_node);\n this.removeChild(ref_node);\n return node;\n },\n\n /**\n * @this {Node}\n */\n cloneNode(deep) {\n return mutation.cloneNode(this, deep);\n },\n\n /**\n * @this {Node}\n */\n getRootNode(options) {\n return mutation.getRootNode(this, options);\n },\n\n /**\n * @this {Node}\n */\n get isConnected() {\n // Fast path for distributed nodes.\n const ownerDocument = this.ownerDocument;\n if (ownerDocument && ownerDocument.contains && ownerDocument.contains(this)) return true;\n const ownerDocumentElement = ownerDocument.documentElement;\n if (ownerDocumentElement && ownerDocumentElement.contains && ownerDocumentElement.contains(this)) return true;\n\n let node = this;\n while (node && !(node instanceof Document)) {\n node = node.parentNode || (node instanceof ShadyRoot ? /** @type {ShadowRoot} */(node).host : undefined);\n }\n return !!(node && node instanceof Document);\n },\n\n /**\n * @this {Node}\n */\n dispatchEvent(event) {\n flush();\n return dispatchEvent.call(this, event);\n }\n\n};\n\n// NOTE: For some reason `Text` redefines `assignedSlot`\nlet textMixin = {\n /**\n * @this {Text}\n */\n get assignedSlot() {\n return getAssignedSlot(this);\n }\n};\n\nlet fragmentMixin = {\n\n // TODO(sorvell): consider doing native QSA and filtering results.\n /**\n * @this {DocumentFragment}\n */\n querySelector(selector) {\n // match selector and halt on first result.\n let result = mutation.query(this, function(n) {\n return utils.matchesSelector(n, selector);\n }, function(n) {\n return Boolean(n);\n })[0];\n return result || null;\n },\n\n /**\n * @this {DocumentFragment}\n */\n querySelectorAll(selector) {\n return mutation.query(this, function(n) {\n return utils.matchesSelector(n, selector);\n });\n }\n\n};\n\nlet slotMixin = {\n\n /**\n * @this {HTMLSlotElement}\n */\n assignedNodes(options) {\n if (this.localName === 'slot') {\n mutation.renderRootNode(this);\n return this.__shady ?\n ((options && options.flatten ? this.__shady.distributedNodes :\n this.__shady.assignedNodes) || []) :\n [];\n }\n }\n\n};\n\nlet elementMixin = utils.extendAll({\n\n /**\n * @this {HTMLElement}\n */\n setAttribute(name, value) {\n mutation.setAttribute(this, name, value);\n },\n\n /**\n * @this {HTMLElement}\n */\n removeAttribute(name) {\n mutation.removeAttribute(this, name);\n },\n\n /**\n * @this {HTMLElement}\n */\n attachShadow(options) {\n return attachShadow(this, options);\n },\n\n /**\n * @this {HTMLElement}\n */\n get slot() {\n return this.getAttribute('slot');\n },\n\n /**\n * @this {HTMLElement}\n */\n set slot(value) {\n this.setAttribute('slot', value);\n },\n\n /**\n * @this {HTMLElement}\n */\n get assignedSlot() {\n return getAssignedSlot(this);\n }\n\n}, fragmentMixin, slotMixin);\n\nObject.defineProperties(elementMixin, ShadowRootAccessor);\n\nlet documentMixin = utils.extendAll({\n /**\n * @this {Document}\n */\n importNode(node, deep) {\n return mutation.importNode(node, deep);\n },\n\n /**\n * @this {Document}\n */\n getElementById(id) {\n return this.querySelector(`#${id}`);\n }\n\n}, fragmentMixin);\n\nObject.defineProperties(documentMixin, {\n '_activeElement': ActiveElementAccessor.activeElement\n});\n\nlet nativeBlur = HTMLElement.prototype.blur;\n\nlet htmlElementMixin = utils.extendAll({\n /**\n * @this {HTMLElement}\n */\n blur() {\n let root = this.shadowRoot;\n let shadowActive = root && root.activeElement;\n if (shadowActive) {\n shadowActive.blur();\n } else {\n nativeBlur.call(this);\n }\n }\n})\n\nfunction patchBuiltin(proto, obj) {\n let n$ = Object.getOwnPropertyNames(obj);\n for (let i=0; i < n$.length; i++) {\n let n = n$[i];\n let d = Object.getOwnPropertyDescriptor(obj, n);\n // NOTE: we prefer writing directly here because some browsers\n // have descriptors that are writable but not configurable (e.g.\n // `appendChild` on older browsers)\n if (d.value) {\n proto[n] = d.value;\n } else {\n Object.defineProperty(proto, n, d);\n }\n }\n}\n\n\n// Apply patches to builtins (e.g. Element.prototype). Some of these patches\n// can be done unconditionally (mostly methods like\n// `Element.prototype.appendChild`) and some can only be done when the browser\n// has proper descriptors on the builtin prototype\n// (e.g. `Element.prototype.firstChild`)`. When descriptors are not available,\n// elements are individually patched when needed (see e.g.\n// `patchInside/OutsideElementAccessors` in `patch-accessors.js`).\nexport function patchBuiltins() {\n let nativeHTMLElement =\n (window['customElements'] && window['customElements']['nativeHTMLElement']) ||\n HTMLElement;\n // These patches can always be done, for all supported browsers.\n patchBuiltin(window.Node.prototype, nodeMixin);\n patchBuiltin(window.Window.prototype, windowMixin);\n patchBuiltin(window.Text.prototype, textMixin);\n patchBuiltin(window.DocumentFragment.prototype, fragmentMixin);\n patchBuiltin(window.Element.prototype, elementMixin);\n patchBuiltin(window.Document.prototype, documentMixin);\n if (window.HTMLSlotElement) {\n patchBuiltin(window.HTMLSlotElement.prototype, slotMixin);\n }\n patchBuiltin(nativeHTMLElement.prototype, htmlElementMixin);\n // These patches can *only* be done\n // on browsers that have proper property descriptors on builtin prototypes.\n // This includes: IE11, Edge, Chrome >= 4?; Safari >= 10, Firefox\n // On older browsers (Chrome <= 4?, Safari 9), a per element patching\n // strategy is used for patching accessors.\n if (utils.settings.hasDescriptors) {\n patchAccessors(window.Node.prototype);\n patchAccessors(window.Text.prototype);\n patchAccessors(window.DocumentFragment.prototype);\n patchAccessors(window.Element.prototype);\n patchAccessors(nativeHTMLElement.prototype);\n patchAccessors(window.Document.prototype);\n if (window.HTMLSlotElement) {\n patchAccessors(window.HTMLSlotElement.prototype);\n }\n }\n}\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n/**\n * Patches elements that interacts with ShadyDOM\n * such that tree traversal and mutation apis act like they would under\n * ShadowDOM.\n *\n * This import enables seemless interaction with ShadyDOM powered\n * custom elements, enabling better interoperation with 3rd party code,\n * libraries, and frameworks that use DOM tree manipulation apis.\n */\n\n'use strict';\nimport * as utils from './utils'\nimport {flush, enqueue} from './flush'\nimport {observeChildren, unobserveChildren, filterMutations} from './observe-changes'\nimport * as nativeMethods from './native-methods'\nimport * as nativeTree from './native-tree'\nimport {patchBuiltins} from './patch-builtins'\nimport {patchEvents} from './patch-events'\nimport {ShadyRoot} from './attach-shadow'\n\nif (utils.settings.inUse) {\n let ShadyDOM = {\n // TODO(sorvell): remove when Polymer does not depend on this.\n 'inUse': utils.settings.inUse,\n // TODO(sorvell): remove when Polymer does not depend on this\n 'patch': (node) => node,\n 'isShadyRoot': utils.isShadyRoot,\n 'enqueue': enqueue,\n 'flush': flush,\n 'settings': utils.settings,\n 'filterMutations': filterMutations,\n 'observeChildren': observeChildren,\n 'unobserveChildren': unobserveChildren,\n 'nativeMethods': nativeMethods,\n 'nativeTree': nativeTree\n };\n\n window['ShadyDOM'] = ShadyDOM;\n\n // Apply patches to events...\n patchEvents();\n // Apply patches to builtins (e.g. Element.prototype) where applicable.\n patchBuiltins();\n\n window.ShadowRoot = ShadyRoot;\n}"]} \ No newline at end of file +{"version":3,"sources":["src/array-splice.js","src/utils.js","src/flush.js","src/innerHTML.js","src/native-tree.js","src/patch-accessors.js","src/logical-tree.js","src/native-methods.js","src/distributor.js","src/attach-shadow.js","src/logical-mutation.js","src/observe-changes.js","src/patch-events.js","src/patch-builtins.js","src/shadydom.js"],"names":["newSplice$$module$$src$array_splice","newSplice","index","addedCount","removed","calcSplices$$module$$src$array_splice","calcSplices","current","currentEnd","old","oldEnd","prefixCount","suffixCount","minLength","Math","min","currentStart","oldStart","i","currentValue","previousValue","length","index1","index2","count","equals","splice","push","rowCount","columnCount","distances","Array","j","north","west","edits","northWest","EDIT_LEAVE","EDIT_UPDATE","EDIT_DELETE","EDIT_ADD","reverse","undefined","splices","oldIndex","equals$$module$$src$array_splice","settings","window","hasNativeShadowDOM","attachShadow","Element","prototype","getRootNode","Node","desc","Object","getOwnPropertyDescriptor","hasDescriptors","configurable","get","inUse","isShadyRoot$$module$$src$utils","isShadyRoot","obj","__localName","ownerShadyRootForNode$$module$$src$utils","ownerShadyRootForNode","node","root","p","matches","matchesSelector","mozMatchesSelector","msMatchesSelector","oMatchesSelector","webkitMatchesSelector","extend$$module$$src$utils","extend","target","source","n$","getOwnPropertyNames","n","pd","defineProperty","extendAll$$module$$src$utils","extendAll","sources","mixin$$module$$src$utils","mixin","twiddle","document","createTextNode","content","queue","observe","MutationObserver","shift","e","textContent","characterData","microtask$$module$$src$utils","microtask","callback","flushList","scheduled","enqueue$$module$$src$flush","enqueue","flush","flush$$module$$src$flush","didFlush","escapeAttrRegExp","escapeDataRegExp","escapeReplace$$module$$src$innerHTML","escapeReplace","c","makeSet$$module$$src$innerHTML","makeSet","arr","set","voidElements","plaintextParents","getInnerHTML$$module$$src$innerHTML","getInnerHTML","localName","s","c$","childNodes","l","child","attr","nodeType","ELEMENT_NODE","tagName","attrs","attributes","name","value","replace","TEXT_NODE","data","parentNode","COMMENT_NODE","console","error","Error","nodeWalker","createTreeWalker","NodeFilter","SHOW_ALL","elementWalker","SHOW_ELEMENT","childNodes$$module$$src$native_tree","nodes","currentNode","firstChild","nextSibling","module$$src$native_tree","parentNode$$module$$src$native_tree","firstChild$$module$$src$native_tree","lastChild","lastChild$$module$$src$native_tree","previousSibling","previousSibling$$module$$src$native_tree","nextSibling$$module$$src$native_tree","parentElement","parentElement$$module$$src$native_tree","firstElementChild","firstElementChild$$module$$src$native_tree","lastElementChild","lastElementChild$$module$$src$native_tree","previousElementSibling","previousElementSibling$$module$$src$native_tree","nextElementSibling","nextElementSibling$$module$$src$native_tree","children","children$$module$$src$native_tree","innerHTML","innerHTML$$module$$src$native_tree","textContent$$module$$src$native_tree","nodeValue","textWalker","SHOW_TEXT","nextNode","nativeInnerHTMLDesc","HTMLElement","htmlContainer","implementation","createHTMLDocument","inertDoc","createElement","nativeActiveElementDescriptor","Document","OutsideAccessors","__shady","className","getAttribute","setAttribute","InsideAccessors","item","childNodes.item","childElementCount","tc","cn","join","text","removeChild","appendChild","filter","call","children.item","ShadowRootAccessor","shadowRoot","ActiveElementAccessor","activeElement","active","host","contains","activeRoot","patchAccessorGroup$$module$$src$patch_accessors","patchAccessorGroup","descriptors","force","objDesc","warn","patchAccessors$$module$$src$patch_accessors","patchAccessors","proto","patchOutsideElementAccessors","element","__outsideAccessors","patchInsideElementAccessors","__insideAccessors","linkNode$$module$$src$logical_tree","linkNode","container","ref_node","ps","ns","recordChildNodes$$module$$src$logical_tree","insertBefore","removeAttribute","cloneNode","importNode","addEventListener","removeEventListener","windowAddEventListener","Window","windowRemoveEventListener","dispatchEvent","module$$src$native_methods","NormalizedEvent","Event","inType","params","createEvent","initEvent","bubbles","cancelable","constructor","insertionPointTag","distribute","hasInsertionPoint","pool","dirtyRoots","p$","_getInsertionPoints","prevAssignedNodes","insertionPoint","assignedNodes","clearAssignedSlots","needsSlotChange","anyDistributed","slotName","trim","slot","_prevAssignedSlot","assignedSlot","distributedNodes","d$","_fireSlotChange","distributeInsertionPoint","parent","savePrevious","isFinalDestination","ShadyRootConstructionToken","ShadyRoot$$module$$src$attach_shadow","token","TypeError","createDocumentFragment","__proto__","ShadyRoot","recordChildNodes","_renderPending","_changePending","_distributor","$jscompDefaultExport","update","create","DocumentFragment","ShadyRoot$$module$$src$attach_shadow.prototype.update","render","ShadyRoot$$module$$src$attach_shadow.prototype.render","renderRoot","_getRenderRoot","_skipUpdateInsertionPoints","updateInsertionPoints","_updateChildNodes","compose","_composeNode","ShadyRoot$$module$$src$attach_shadow.prototype.distribute","ShadyRoot$$module$$src$attach_shadow.prototype.updateInsertionPoints","i$","_insertionPoints","querySelectorAll","ShadyRoot$$module$$src$attach_shadow.prototype._composeNode","distributedNode","ShadyRoot$$module$$src$attach_shadow.prototype.isFinalDestination","ShadyRoot$$module$$src$attach_shadow.prototype._updateChildNodes","composed","d","next","ShadyRoot$$module$$src$attach_shadow.prototype.hasInsertionPoint","ShadyRoot$$module$$src$attach_shadow.prototype._getInsertionPoints","ShadyRoot$$module$$src$attach_shadow.prototype.addEventListener","type","fn","optionsOrCapture","capture","__shadyTarget","ShadyRoot$$module$$src$attach_shadow.prototype.removeEventListener","getElementById","ShadyRoot$$module$$src$attach_shadow.prototype.getElementById","id","querySelector","removeNode$$module$$src$logical_mutation","removeNode","logicalParent","distributed","ownerRoot","maybeDistributeParent","hostNeedsDist","ip$","dc$","flatten","addedInsertionPoint","removedDistributed","updateRootViaContentChange","_removeOwnerShadyRoot","_scheduleObserver$$module$$src$logical_mutation","_scheduleObserver","addedNode","removedNode","observer","addedNodes","removedNodes","schedule","getRootNode$$module$$src$logical_mutation","ownerShadyRoot","documentElement","_maybeAddInsertionPoint$$module$$src$logical_mutation","_maybeAddInsertionPoint","added","DOCUMENT_FRAGMENT_NODE","np","na","_nodeNeedsDistribution$$module$$src$logical_mutation","_nodeNeedsDistribution","_removeOwnerShadyRoot$$module$$src$logical_mutation","maybeDistributeParent$$module$$src$logical_mutation","updateRootViaContentChange$$module$$src$logical_mutation","distributeAttributeChange$$module$$src$logical_mutation","distributeAttributeChange","query$$module$$src$logical_mutation","query","matcher","halter","list","_queryElements","_queryElements$$module$$src$logical_mutation","elements","result","scopingShim","insertBefore$$module$$src$logical_mutation","ipAdded","resetTo","fragContent","wrappedContent","hasContent","needsDist","handled","importNode$$module$$src$logical_mutation","deep","ownerDocument","nc","AsyncObserver","_scheduled","callbacks","Set","mutations","takeRecords","forEach","cb","observeChildren$$module$$src$observe_changes","add","_callback","_observer","_node","unobserveChildren$$module$$src$observe_changes","handle","delete","size","filterMutations$$module$$src$observe_changes","filterMutations","targetRootNode","map","mutation","mutationInScope","from","m","alwaysComposed","pathComposer$$module$$src$patch_events","pathComposer","startNode","composedPath","startRoot","retarget$$module$$src$patch_events","retarget","refNode","path","refNodePath","ancestor","lastRoot","rootIdx","indexOf","eventMixin","isTrusted","__composed","__composedPath","currentTarget","relatedTarget","__relatedTarget","__relatedTargetComposedPath","stopPropagation","__propagationStopped","stopImmediatePropagation","__immediatePropagationStopped","mixinComposedFlag$$module$$src$patch_events","mixinComposedFlag","Base","klazz","options","event","nonBubblingEventsToRetarget","fireHandlers$$module$$src$patch_events","fireHandlers","phase","hs","__handlers","retargetNonBubblingEvent$$module$$src$patch_events","retargetNonBubblingEvent","AT_TARGET","lastFiredRoot","findListener$$module$$src$patch_events","findListener","wrappers","once","passive","savedType","savedListener","savedCapture","savedOnce","savedPassive","savedNode","addEventListener$$module$$src$patch_events","fnOrObj","__eventWrappers","wrapperFn","patchEvent","lastCurrentTargetDesc","eventPhase","BUBBLING_PHASE","CAPTURING_PHASE","ret","handleEvent","ael","removeEventListener$$module$$src$patch_events","idx","rel","activateFocusEventOverrides$$module$$src$patch_events","activateFocusEventOverrides","ev","patchEvent$$module$$src$patch_events","getPrototypeOf","hasOwnProperty","patchProto","__sourceProto","PatchedEvent","PatchedCustomEvent","CustomEvent","PatchedMouseEvent","MouseEvent","getAssignedSlot$$module$$src$patch_builtins","getAssignedSlot","windowMixin","bind","nodeMixin","nativeParent","replaceChild","isConnected","ownerDocumentElement","textMixin","fragmentMixin","selector","slotMixin","elementMixin","defineProperties","documentMixin","nativeBlur","blur","htmlElementMixin","shadowActive","patchBuiltin$$module$$src$patch_builtins","patchBuiltin","ShadyDOM","patch","observeChildren","unobserveChildren","nativeHTMLElement","Text","HTMLSlotElement","ShadowRoot"],"mappings":"A;;;;;;;;;;aAYAA,QAASC,EAAS,CAACC,CAAD,CAAiBC,CAAjB,CAA6B,CAC7C,MAAO,CACLD,MAAOA,CADF,CAELE,EAwJiCA,EA1J5B,CAGLD,EAAYA,CAHP,CADsC;AAqI/CE,QAASC,GAAW,CAACC,CAAD,CAAwBC,CAAxB,CACEC,CADF,CACiBC,CADjB,CACyB,CAuGf,IAAA,EAAA,CAAA,CAA6B,EAAA,CAA7B,CAtGxBC,EAAc,CAsGU,CArGxBC,EAAc,CAqGU,CAlGxBC,EAAYC,IAAAC,IAAA,CAASP,CAAT,CAAsBQ,CAAtB,CAAoCN,CAApC,CAA6CO,CAA7C,CAChB,IAAoB,CAApB,EAAID,CAAJ,EAAqC,CAArC,EAAyBC,CAAzB,CA2EgD,CAAA,CAAA,CAChD,IAASC,CAAT,CAAa,CAAb,CAAgBA,CAAhB,CA3E2CL,CA2E3C,CAAkCK,CAAA,EAAlC,CACE,GA5E2BX,CA4EfY,CAAQD,CAARC,CAAZ,GA5EoCV,CA4EZW,CAAIF,CAAJE,CAAxB,CACE,MAAA,CACJ,EAAA,CA9E2CP,CA0EK,CAxEhD,GAAIL,CAAJ,EAAkBD,CAAAc,OAAlB,EAAoCX,CAApC,EAA8CD,CAAAY,OAA9C,CAAA,CAmFA,IAHIC,IAAAA,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LvBShP,CKDe","file":"shadydom.min.js","sourcesContent":["/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nfunction newSplice(index, removed, addedCount) {\n return {\n index: index,\n removed: removed,\n addedCount: addedCount\n };\n}\n\nconst EDIT_LEAVE = 0;\nconst EDIT_UPDATE = 1;\nconst EDIT_ADD = 2;\nconst EDIT_DELETE = 3;\n\n// Note: This function is *based* on the computation of the Levenshtein\n// \"edit\" distance. The one change is that \"updates\" are treated as two\n// edits - not one. With Array splices, an update is really a delete\n// followed by an add. By retaining this, we optimize for \"keeping\" the\n// maximum array items in the original array. For example:\n//\n// 'xxxx123' -> '123yyyy'\n//\n// With 1-edit updates, the shortest path would be just to update all seven\n// characters. With 2-edit updates, we delete 4, leave 3, and add 4. This\n// leaves the substring '123' intact.\nfunction calcEditDistances(current, currentStart, currentEnd,\n old, oldStart, oldEnd) {\n // \"Deletion\" columns\n let rowCount = oldEnd - oldStart + 1;\n let columnCount = currentEnd - currentStart + 1;\n let distances = new Array(rowCount);\n\n // \"Addition\" rows. Initialize null column.\n for (let i = 0; i < rowCount; i++) {\n distances[i] = new Array(columnCount);\n distances[i][0] = i;\n }\n\n // Initialize null row\n for (let j = 0; j < columnCount; j++)\n distances[0][j] = j;\n\n for (let i = 1; i < rowCount; i++) {\n for (let j = 1; j < columnCount; j++) {\n if (equals(current[currentStart + j - 1], old[oldStart + i - 1]))\n distances[i][j] = distances[i - 1][j - 1];\n else {\n let north = distances[i - 1][j] + 1;\n let west = distances[i][j - 1] + 1;\n distances[i][j] = north < west ? north : west;\n }\n }\n }\n\n return distances;\n}\n\n// This starts at the final weight, and walks \"backward\" by finding\n// the minimum previous weight recursively until the origin of the weight\n// matrix.\nfunction spliceOperationsFromEditDistances(distances) {\n let i = distances.length - 1;\n let j = distances[0].length - 1;\n let current = distances[i][j];\n let edits = [];\n while (i > 0 || j > 0) {\n if (i == 0) {\n edits.push(EDIT_ADD);\n j--;\n continue;\n }\n if (j == 0) {\n edits.push(EDIT_DELETE);\n i--;\n continue;\n }\n let northWest = distances[i - 1][j - 1];\n let west = distances[i - 1][j];\n let north = distances[i][j - 1];\n\n let min;\n if (west < north)\n min = west < northWest ? west : northWest;\n else\n min = north < northWest ? north : northWest;\n\n if (min == northWest) {\n if (northWest == current) {\n edits.push(EDIT_LEAVE);\n } else {\n edits.push(EDIT_UPDATE);\n current = northWest;\n }\n i--;\n j--;\n } else if (min == west) {\n edits.push(EDIT_DELETE);\n i--;\n current = west;\n } else {\n edits.push(EDIT_ADD);\n j--;\n current = north;\n }\n }\n\n edits.reverse();\n return edits;\n}\n\n/**\n * Splice Projection functions:\n *\n * A splice map is a representation of how a previous array of items\n * was transformed into a new array of items. Conceptually it is a list of\n * tuples of\n *\n * \n *\n * which are kept in ascending index order of. The tuple represents that at\n * the |index|, |removed| sequence of items were removed, and counting forward\n * from |index|, |addedCount| items were added.\n */\n\n/**\n * Lacking individual splice mutation information, the minimal set of\n * splices can be synthesized given the previous state and final state of an\n * array. The basic approach is to calculate the edit distance matrix and\n * choose the shortest path through it.\n *\n * Complexity: O(l * p)\n * l: The length of the current array\n * p: The length of the old array\n */\nfunction calcSplices(current, currentStart, currentEnd,\n old, oldStart, oldEnd) {\n let prefixCount = 0;\n let suffixCount = 0;\n let splice;\n\n let minLength = Math.min(currentEnd - currentStart, oldEnd - oldStart);\n if (currentStart == 0 && oldStart == 0)\n prefixCount = sharedPrefix(current, old, minLength);\n\n if (currentEnd == current.length && oldEnd == old.length)\n suffixCount = sharedSuffix(current, old, minLength - prefixCount);\n\n currentStart += prefixCount;\n oldStart += prefixCount;\n currentEnd -= suffixCount;\n oldEnd -= suffixCount;\n\n if (currentEnd - currentStart == 0 && oldEnd - oldStart == 0)\n return [];\n\n if (currentStart == currentEnd) {\n splice = newSplice(currentStart, [], 0);\n while (oldStart < oldEnd)\n splice.removed.push(old[oldStart++]);\n\n return [ splice ];\n } else if (oldStart == oldEnd)\n return [ newSplice(currentStart, [], currentEnd - currentStart) ];\n\n let ops = spliceOperationsFromEditDistances(\n calcEditDistances(current, currentStart, currentEnd,\n old, oldStart, oldEnd));\n\n splice = undefined;\n let splices = [];\n let index = currentStart;\n let oldIndex = oldStart;\n for (let i = 0; i < ops.length; i++) {\n switch(ops[i]) {\n case EDIT_LEAVE:\n if (splice) {\n splices.push(splice);\n splice = undefined;\n }\n\n index++;\n oldIndex++;\n break;\n case EDIT_UPDATE:\n if (!splice)\n splice = newSplice(index, [], 0);\n\n splice.addedCount++;\n index++;\n\n splice.removed.push(old[oldIndex]);\n oldIndex++;\n break;\n case EDIT_ADD:\n if (!splice)\n splice = newSplice(index, [], 0);\n\n splice.addedCount++;\n index++;\n break;\n case EDIT_DELETE:\n if (!splice)\n splice = newSplice(index, [], 0);\n\n splice.removed.push(old[oldIndex]);\n oldIndex++;\n break;\n }\n }\n\n if (splice) {\n splices.push(splice);\n }\n return splices;\n}\n\nfunction sharedPrefix(current, old, searchLength) {\n for (let i = 0; i < searchLength; i++)\n if (!equals(current[i], old[i]))\n return i;\n return searchLength;\n}\n\nfunction sharedSuffix(current, old, searchLength) {\n let index1 = current.length;\n let index2 = old.length;\n let count = 0;\n while (count < searchLength && equals(current[--index1], old[--index2]))\n count++;\n\n return count;\n}\n\nfunction equals(currentValue, previousValue) {\n return currentValue === previousValue;\n}\n\nexport function calculateSplices(current, previous) {\n return calcSplices(current, 0, current.length, previous, 0,\n previous.length);\n}\n\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nexport let settings = window['ShadyDOM'] || {};\n\nsettings.hasNativeShadowDOM = Boolean(Element.prototype.attachShadow && Node.prototype.getRootNode);\n\nlet desc = Object.getOwnPropertyDescriptor(Node.prototype, 'firstChild');\n\nsettings.hasDescriptors = Boolean(desc && desc.configurable && desc.get);\nsettings.inUse = settings['force'] || !settings.hasNativeShadowDOM;\n\nexport function isShadyRoot(obj) {\n return Boolean(obj.__localName === 'ShadyRoot');\n}\n\nexport function ownerShadyRootForNode(node) {\n let root = node.getRootNode();\n if (isShadyRoot(root)) {\n return root;\n }\n}\n\nlet p = Element.prototype;\nlet matches = p.matches || p.matchesSelector ||\n p.mozMatchesSelector || p.msMatchesSelector ||\n p.oMatchesSelector || p.webkitMatchesSelector;\n\nexport function matchesSelector(element, selector) {\n return matches.call(element, selector);\n}\n\nfunction copyOwnProperty(name, source, target) {\n let pd = Object.getOwnPropertyDescriptor(source, name);\n if (pd) {\n Object.defineProperty(target, name, pd);\n }\n}\n\nexport function extend(target, source) {\n if (target && source) {\n let n$ = Object.getOwnPropertyNames(source);\n for (let i=0, n; (i {\n while (queue.length) {\n // catch errors in user code...\n try {\n queue.shift()();\n } catch(e) {\n // enqueue another record and throw\n twiddle.textContent = content++;\n throw(e);\n }\n }\n}).observe(twiddle, {characterData: true});\n\n// use MutationObserver to get microtask async timing.\nexport function microtask(callback) {\n queue.push(callback);\n twiddle.textContent = content++;\n}","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport * as utils from './utils'\n\n// render enqueuer/flusher\nlet flushList = [];\nlet scheduled;\nexport function enqueue(callback) {\n if (!scheduled) {\n scheduled = true;\n utils.microtask(flush);\n }\n flushList.push(callback);\n}\n\nexport function flush() {\n scheduled = false;\n let didFlush = Boolean(flushList.length);\n while (flushList.length) {\n flushList.shift()();\n }\n return didFlush;\n}\n\nflush['list'] = flushList;","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\n// Cribbed from ShadowDOM polyfill\n// https://github.com/webcomponents/webcomponentsjs/blob/master/src/ShadowDOM/wrappers/HTMLElement.js#L28\n/////////////////////////////////////////////////////////////////////////////\n// innerHTML and outerHTML\n\n// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#escapingString\nlet escapeAttrRegExp = /[&\\u00A0\"]/g;\nlet escapeDataRegExp = /[&\\u00A0<>]/g;\n\nfunction escapeReplace(c) {\n switch (c) {\n case '&':\n return '&';\n case '<':\n return '<';\n case '>':\n return '>';\n case '\"':\n return '"';\n case '\\u00A0':\n return ' ';\n }\n}\n\nfunction escapeAttr(s) {\n return s.replace(escapeAttrRegExp, escapeReplace);\n}\n\nfunction escapeData(s) {\n return s.replace(escapeDataRegExp, escapeReplace);\n}\n\nfunction makeSet(arr) {\n let set = {};\n for (let i = 0; i < arr.length; i++) {\n set[arr[i]] = true;\n }\n return set;\n}\n\n// http://www.whatwg.org/specs/web-apps/current-work/#void-elements\nlet voidElements = makeSet([\n 'area',\n 'base',\n 'br',\n 'col',\n 'command',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'keygen',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr'\n]);\n\nlet plaintextParents = makeSet([\n 'style',\n 'script',\n 'xmp',\n 'iframe',\n 'noembed',\n 'noframes',\n 'plaintext',\n 'noscript'\n]);\n\n/**\n * @param {Node} node\n * @param {Node} parentNode\n * @param {Function=} callback\n */\nexport function getOuterHTML(node, parentNode, callback) {\n switch (node.nodeType) {\n case Node.ELEMENT_NODE: {\n let tagName = node.localName;\n let s = '<' + tagName;\n let attrs = node.attributes;\n for (let i = 0, attr; (attr = attrs[i]); i++) {\n s += ' ' + attr.name + '=\"' + escapeAttr(attr.value) + '\"';\n }\n s += '>';\n if (voidElements[tagName]) {\n return s;\n }\n return s + getInnerHTML(node, callback) + '';\n }\n case Node.TEXT_NODE: {\n let data = /** @type {Text} */ (node).data;\n if (parentNode && plaintextParents[parentNode.localName]) {\n return data;\n }\n return escapeData(data);\n }\n case Node.COMMENT_NODE: {\n return '';\n }\n default: {\n window.console.error(node);\n throw new Error('not implemented');\n }\n }\n}\n\n/**\n * @param {Node} node\n * @param {Function=} callback\n */\nexport function getInnerHTML(node, callback) {\n if (node.localName === 'template') {\n node = /** @type {HTMLTemplateElement} */ (node).content;\n }\n let s = '';\n let c$ = callback ? callback(node) : node.childNodes;\n for (let i=0, l=c$.length, child; (i childNodes(n));\n}\n\nexport function textContent(node) {\n if (node.nodeType !== Node.ELEMENT_NODE) {\n return node.nodeValue;\n }\n let textWalker = document.createTreeWalker(node, NodeFilter.SHOW_TEXT,\n null, false);\n let content = '', n;\n while ( (n = textWalker.nextNode()) ) {\n // TODO(sorvell): can't use textContent since we patch it on Node.prototype!\n // However, should probably patch it only on element.\n content += n.nodeValue;\n }\n return content;\n}","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport * as utils from './utils'\nimport {getInnerHTML} from './innerHTML'\nimport * as nativeTree from './native-tree'\n\nfunction clearNode(node) {\n while (node.firstChild) {\n node.removeChild(node.firstChild);\n }\n}\n\nconst nativeInnerHTMLDesc = /** @type {ObjectPropertyDescriptor} */(\n Object.getOwnPropertyDescriptor(Element.prototype, 'innerHTML') ||\n Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'innerHTML'));\n\nconst inertDoc = document.implementation.createHTMLDocument('inert');\nconst htmlContainer = inertDoc.createElement('div');\n\nconst nativeActiveElementDescriptor =\n /** @type {ObjectPropertyDescriptor} */(\n Object.getOwnPropertyDescriptor(Document.prototype, 'activeElement')\n );\nfunction getDocumentActiveElement() {\n if (nativeActiveElementDescriptor && nativeActiveElementDescriptor.get) {\n return nativeActiveElementDescriptor.get.call(document);\n } else if (!utils.settings.hasDescriptors) {\n return document.activeElement;\n }\n}\n\nfunction activeElementForNode(node) {\n let active = getDocumentActiveElement();\n // In IE11, activeElement might be an empty object if the document is\n // contained in an iframe.\n // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10998788/\n if (!active || !active.nodeType) {\n return null;\n }\n let isShadyRoot = !!(utils.isShadyRoot(node));\n if (node !== document) {\n // If this node isn't a document or shady root, then it doesn't have\n // an active element.\n if (!isShadyRoot) {\n return null;\n }\n // If this shady root's host is the active element or the active\n // element is not a descendant of the host (in the composed tree),\n // then it doesn't have an active element.\n if (node.host === active ||\n !node.host.contains(active)) {\n return null;\n }\n }\n // This node is either the document or a shady root of which the active\n // element is a (composed) descendant of its host; iterate upwards to\n // find the active element's most shallow host within it.\n let activeRoot = utils.ownerShadyRootForNode(active);\n while (activeRoot && activeRoot !== node) {\n active = activeRoot.host;\n activeRoot = utils.ownerShadyRootForNode(active);\n }\n if (node === document) {\n // This node is the document, so activeRoot should be null.\n return activeRoot ? null : active;\n } else {\n // This node is a non-document shady root, and it should be\n // activeRoot.\n return activeRoot === node ? active : null;\n }\n}\n\nlet OutsideAccessors = {\n\n parentElement: {\n /** @this {Node} */\n get() {\n let l = this.__shady && this.__shady.parentNode;\n if (l && l.nodeType !== Node.ELEMENT_NODE) {\n l = null;\n }\n return l !== undefined ? l : nativeTree.parentElement(this);\n },\n configurable: true\n },\n\n parentNode: {\n /** @this {Node} */\n get() {\n let l = this.__shady && this.__shady.parentNode;\n return l !== undefined ? l : nativeTree.parentNode(this);\n },\n configurable: true\n },\n\n nextSibling: {\n /** @this {Node} */\n get() {\n let l = this.__shady && this.__shady.nextSibling;\n return l !== undefined ? l : nativeTree.nextSibling(this);\n },\n configurable: true\n },\n\n previousSibling: {\n /** @this {Node} */\n get() {\n let l = this.__shady && this.__shady.previousSibling;\n return l !== undefined ? l : nativeTree.previousSibling(this);\n },\n configurable: true\n },\n\n className: {\n /**\n * @this {HTMLElement}\n */\n get() {\n return this.getAttribute('class') || '';\n },\n /**\n * @this {HTMLElement}\n */\n set(value) {\n this.setAttribute('class', value);\n },\n configurable: true\n },\n\n // fragment, element, document\n nextElementSibling: {\n /**\n * @this {HTMLElement}\n */\n get() {\n if (this.__shady && this.__shady.nextSibling !== undefined) {\n let n = this.nextSibling;\n while (n && n.nodeType !== Node.ELEMENT_NODE) {\n n = n.nextSibling;\n }\n return n;\n } else {\n return nativeTree.nextElementSibling(this);\n }\n },\n configurable: true\n },\n\n previousElementSibling: {\n /**\n * @this {HTMLElement}\n */\n get() {\n if (this.__shady && this.__shady.previousSibling !== undefined) {\n let n = this.previousSibling;\n while (n && n.nodeType !== Node.ELEMENT_NODE) {\n n = n.previousSibling;\n }\n return n;\n } else {\n return nativeTree.previousElementSibling(this);\n }\n },\n configurable: true\n }\n\n};\n\nlet InsideAccessors = {\n\n childNodes: {\n /**\n * @this {HTMLElement}\n */\n get() {\n let childNodes;\n if (this.__shady && this.__shady.firstChild !== undefined) {\n if (!this.__shady.childNodes) {\n this.__shady.childNodes = [];\n for (let n=this.firstChild; n; n=n.nextSibling) {\n this.__shady.childNodes.push(n);\n }\n }\n childNodes = this.__shady.childNodes;\n } else {\n childNodes = nativeTree.childNodes(this);\n }\n childNodes.item = function(index) {\n return childNodes[index];\n }\n return childNodes;\n },\n configurable: true\n },\n\n childElementCount: {\n /** @this {HTMLElement} */\n get() {\n return this.children.length;\n },\n configurable: true\n },\n\n firstChild: {\n /** @this {HTMLElement} */\n get() {\n let l = this.__shady && this.__shady.firstChild;\n return l !== undefined ? l : nativeTree.firstChild(this);\n },\n configurable: true\n },\n\n lastChild: {\n /** @this {HTMLElement} */\n get() {\n let l = this.__shady && this.__shady.lastChild;\n return l !== undefined ? l : nativeTree.lastChild(this);\n },\n configurable: true\n },\n\n textContent: {\n /**\n * @this {HTMLElement}\n */\n get() {\n if (this.__shady && this.__shady.firstChild !== undefined) {\n let tc = [];\n for (let i = 0, cn = this.childNodes, c; (c = cn[i]); i++) {\n if (c.nodeType !== Node.COMMENT_NODE) {\n tc.push(c.textContent);\n }\n }\n return tc.join('');\n } else {\n return nativeTree.textContent(this);\n }\n },\n /**\n * @this {HTMLElement}\n */\n set(text) {\n if (this.nodeType !== Node.ELEMENT_NODE) {\n // TODO(sorvell): can't do this if patch nodeValue.\n this.nodeValue = text;\n } else {\n clearNode(this);\n this.appendChild(document.createTextNode(text));\n }\n },\n configurable: true\n },\n\n // fragment, element, document\n firstElementChild: {\n /**\n * @this {HTMLElement}\n */\n get() {\n if (this.__shady && this.__shady.firstChild !== undefined) {\n let n = this.firstChild;\n while (n && n.nodeType !== Node.ELEMENT_NODE) {\n n = n.nextSibling;\n }\n return n;\n } else {\n return nativeTree.firstElementChild(this);\n }\n },\n configurable: true\n },\n\n lastElementChild: {\n /**\n * @this {HTMLElement}\n */\n get() {\n if (this.__shady && this.__shady.lastChild !== undefined) {\n let n = this.lastChild;\n while (n && n.nodeType !== Node.ELEMENT_NODE) {\n n = n.previousSibling;\n }\n return n;\n } else {\n return nativeTree.lastElementChild(this);\n }\n },\n configurable: true\n },\n\n children: {\n /**\n * @this {HTMLElement}\n */\n get() {\n let children;\n if (this.__shady && this.__shady.firstChild !== undefined) {\n children = Array.prototype.filter.call(this.childNodes, function(n) {\n return (n.nodeType === Node.ELEMENT_NODE);\n });\n } else {\n children = nativeTree.children(this);\n }\n children.item = function(index) {\n return children[index];\n }\n return children;\n },\n configurable: true\n },\n\n // element (HTMLElement on IE11)\n innerHTML: {\n /**\n * @this {HTMLElement}\n */\n get() {\n let content = this.localName === 'template' ?\n /** @type {HTMLTemplateElement} */(this).content : this;\n if (this.__shady && this.__shady.firstChild !== undefined) {\n return getInnerHTML(content);\n } else {\n return nativeTree.innerHTML(content);\n }\n },\n /**\n * @this {HTMLElement}\n */\n set(text) {\n let content = this.localName === 'template' ?\n /** @type {HTMLTemplateElement} */(this).content : this;\n clearNode(content);\n if (nativeInnerHTMLDesc && nativeInnerHTMLDesc.set) {\n nativeInnerHTMLDesc.set.call(htmlContainer, text);\n } else {\n htmlContainer.innerHTML = text;\n }\n while (htmlContainer.firstChild) {\n content.appendChild(htmlContainer.firstChild);\n }\n },\n configurable: true\n }\n\n};\n\n// Note: Can be patched on element prototype on all browsers.\n// Must be patched on instance on browsers that support native Shadow DOM\n// but do not have builtin accessors (old Chrome).\nexport let ShadowRootAccessor = {\n\n shadowRoot: {\n /**\n * @this {HTMLElement}\n */\n get() {\n return this.__shady && this.__shady.root || null;\n },\n /**\n * @this {HTMLElement}\n */\n set(value) {\n this.__shady = this.__shady || {};\n this.__shady.root = value;\n },\n configurable: true\n }\n};\n\n// Note: Can be patched on document prototype on browsers with builtin accessors.\n// Must be patched separately on simulated ShadowRoot.\n// Must be patched as `_activeElement` on browsers without builtin accessors.\nexport let ActiveElementAccessor = {\n\n activeElement: {\n /**\n * @this {HTMLElement}\n */\n get() {\n return activeElementForNode(this);\n },\n /**\n * @this {HTMLElement}\n */\n set() {},\n configurable: true\n }\n\n};\n\n// patch a group of descriptors on an object only if it exists or if the `force`\n// argument is true.\n/**\n * @param {!Object} obj\n * @param {!Object} descriptors\n * @param {boolean=} force\n */\nfunction patchAccessorGroup(obj, descriptors, force) {\n for (let p in descriptors) {\n let objDesc = Object.getOwnPropertyDescriptor(obj, p);\n if ((objDesc && objDesc.configurable) ||\n (!objDesc && force)) {\n Object.defineProperty(obj, p, descriptors[p]);\n } else if (force) {\n console.warn('Could not define', p, 'on', obj);\n }\n }\n}\n\n// patch dom accessors on proto where they exist\nexport function patchAccessors(proto) {\n patchAccessorGroup(proto, OutsideAccessors);\n patchAccessorGroup(proto, InsideAccessors);\n patchAccessorGroup(proto, ActiveElementAccessor);\n}\n\n// ensure element descriptors (IE/Edge don't have em)\nexport function patchShadowRootAccessors(proto) {\n patchAccessorGroup(proto, InsideAccessors, true);\n patchAccessorGroup(proto, ActiveElementAccessor, true);\n}\n\n// ensure an element has patched \"outside\" accessors; no-op when not needed\nexport let patchOutsideElementAccessors = utils.settings.hasDescriptors ?\n function() {} : function(element) {\n if (!(element.__shady && element.__shady.__outsideAccessors)) {\n element.__shady = element.__shady || {};\n element.__shady.__outsideAccessors = true;\n patchAccessorGroup(element, OutsideAccessors, true);\n }\n }\n\n// ensure an element has patched \"inside\" accessors; no-op when not needed\nexport let patchInsideElementAccessors = utils.settings.hasDescriptors ?\n function() {} : function(element) {\n if (!(element.__shady && element.__shady.__insideAccessors)) {\n element.__shady = element.__shady || {};\n element.__shady.__insideAccessors = true;\n patchAccessorGroup(element, InsideAccessors, true);\n patchAccessorGroup(element, ShadowRootAccessor, true);\n }\n }\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport {patchInsideElementAccessors, patchOutsideElementAccessors} from './patch-accessors'\nimport {firstChild, lastChild, childNodes} from './native-tree'\n\nexport function recordInsertBefore(node, container, ref_node) {\n patchInsideElementAccessors(container);\n container.__shady = container.__shady || {};\n if (container.__shady.firstChild !== undefined) {\n container.__shady.childNodes = null;\n }\n // handle document fragments\n if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n let c$ = node.childNodes;\n for (let i=0; i < c$.length; i++) {\n linkNode(c$[i], container, ref_node);\n }\n // cleanup logical dom in doc fragment.\n node.__shady = node.__shady || {};\n let resetTo = (node.__shady.firstChild !== undefined) ? null : undefined;\n node.__shady.firstChild = node.__shady.lastChild = resetTo;\n node.__shady.childNodes = resetTo;\n } else {\n linkNode(node, container, ref_node);\n }\n}\n\nfunction linkNode(node, container, ref_node) {\n patchOutsideElementAccessors(node);\n ref_node = ref_node || null;\n node.__shady = node.__shady || {};\n container.__shady = container.__shady || {};\n if (ref_node) {\n ref_node.__shady = ref_node.__shady || {};\n }\n // update ref_node.previousSibling <-> node\n node.__shady.previousSibling = ref_node ? ref_node.__shady.previousSibling :\n container.lastChild;\n let ps = node.__shady.previousSibling;\n if (ps && ps.__shady) {\n ps.__shady.nextSibling = node;\n }\n // update node <-> ref_node\n let ns = node.__shady.nextSibling = ref_node;\n if (ns && ns.__shady) {\n ns.__shady.previousSibling = node;\n }\n // update node <-> container\n node.__shady.parentNode = container;\n if (ref_node) {\n if (ref_node === container.__shady.firstChild) {\n container.__shady.firstChild = node;\n }\n } else {\n container.__shady.lastChild = node;\n if (!container.__shady.firstChild) {\n container.__shady.firstChild = node;\n }\n }\n // remove caching of childNodes\n container.__shady.childNodes = null;\n}\n\nexport function recordRemoveChild(node, container) {\n node.__shady = node.__shady || {};\n container.__shady = container.__shady || {};\n if (node === container.__shady.firstChild) {\n container.__shady.firstChild = node.__shady.nextSibling;\n }\n if (node === container.__shady.lastChild) {\n container.__shady.lastChild = node.__shady.previousSibling;\n }\n let p = node.__shady.previousSibling;\n let n = node.__shady.nextSibling;\n if (p) {\n p.__shady = p.__shady || {};\n p.__shady.nextSibling = n;\n }\n if (n) {\n n.__shady = n.__shady || {};\n n.__shady.previousSibling = p;\n }\n // When an element is removed, logical data is no longer tracked.\n // Explicitly set `undefined` here to indicate this. This is disginguished\n // from `null` which is set if info is null.\n node.__shady.parentNode = node.__shady.previousSibling =\n node.__shady.nextSibling = undefined;\n if (container.__shady.childNodes !== undefined) {\n // remove caching of childNodes\n container.__shady.childNodes = null;\n }\n}\n\nexport let recordChildNodes = function(node) {\n if (!node.__shady || node.__shady.firstChild === undefined) {\n node.__shady = node.__shady || {};\n node.__shady.firstChild = firstChild(node);\n node.__shady.lastChild = lastChild(node);\n patchInsideElementAccessors(node);\n let c$ = node.__shady.childNodes = childNodes(node);\n for (let i=0, n; (i host\n host.shadowRoot = this;\n this.host = host;\n // state flags\n this._renderPending = false;\n this._hasRendered = false;\n this._changePending = false;\n this._distributor = new Distributor(this);\n this.update();\n}\n\n\n// async render\nShadyRoot.prototype.update = function() {\n if (!this._renderPending) {\n this._renderPending = true;\n enqueue(() => this.render());\n }\n}\n\n// returns the oldest renderPending ancestor root.\nShadyRoot.prototype._getRenderRoot = function() {\n let renderRoot = this;\n let root = this;\n while (root) {\n if (root._renderPending) {\n renderRoot = root;\n }\n root = root._rendererForHost();\n }\n return renderRoot;\n}\n\n// Returns the shadyRoot `this.host` if `this.host`\n// has children that require distribution.\nShadyRoot.prototype._rendererForHost = function() {\n let root = this.host.getRootNode();\n if (utils.isShadyRoot(root)) {\n let c$ = this.host.childNodes;\n for (let i=0, c; i < c$.length; i++) {\n c = c$[i];\n if (this._distributor.isInsertionPoint(c)) {\n return root;\n }\n }\n }\n}\n\nShadyRoot.prototype.render = function() {\n if (this._renderPending) {\n this._getRenderRoot()['_render']();\n }\n}\n\n// NOTE: avoid renaming to ease testability.\nShadyRoot.prototype['_render'] = function() {\n this._renderPending = false;\n this._changePending = false;\n if (!this._skipUpdateInsertionPoints) {\n this.updateInsertionPoints();\n } else if (!this._hasRendered) {\n this.__insertionPoints = [];\n }\n this._skipUpdateInsertionPoints = false;\n // TODO(sorvell): can add a first render optimization here\n // to use if there are no insertion points\n // 1. clear host node of composed children\n // 2. appendChild the shadowRoot itself or (more robust) its logical children\n // NOTE: this didn't seem worth it in perf testing\n // but not ready to delete this info.\n // logical\n this.distribute();\n // physical\n this.compose();\n this._hasRendered = true;\n}\n\nShadyRoot.prototype.forceRender = function() {\n this._renderPending = true;\n this.render();\n}\n\nShadyRoot.prototype.distribute = function() {\n let dirtyRoots = this._distributor.distribute();\n for (let i=0; i children but since this case is assumed to be exceedingly\n // rare, we avoid the cost and will address with some specific api\n // when the need arises. For now, the user must call\n // distributeContent(true), which updates insertion points manually\n // and forces distribution.\n let insertionPointTag = ownerRoot && ownerRoot.getInsertionPointTag() || '';\n let fragContent = (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) &&\n !node['__noInsertionPoint'] &&\n insertionPointTag && node.querySelector(insertionPointTag);\n let wrappedContent = fragContent &&\n (fragContent.parentNode.nodeType !==\n Node.DOCUMENT_FRAGMENT_NODE);\n let hasContent = fragContent || (node.localName === insertionPointTag);\n // There are 3 possible cases where a distribution may need to occur:\n // 1. being inserted (the host of the shady root where\n // content is inserted needs distribution)\n // 2. children being inserted into parent with a shady root (parent\n // needs distribution)\n // 3. container is an insertionPoint\n if (hasContent || (container.localName === insertionPointTag) || ipAdded) {\n if (ownerRoot) {\n // note, insertion point list update is handled after node\n // mutations are complete\n updateRootViaContentChange(ownerRoot);\n }\n }\n let needsDist = _nodeNeedsDistribution(container);\n if (needsDist) {\n let root = container.__shady && container.__shady.root;\n updateRootViaContentChange(root);\n }\n // Return true when distribution will fully handle the composition\n // Note that if a content was being inserted that was wrapped by a node,\n // and the parent does not need distribution, return false to allow\n // the nodes to be added directly, after which children may be\n // distributed and composed into the wrapping node(s)\n return needsDist || (hasContent && !wrappedContent);\n}\n\n/* note: parent argument is required since node may have an out\nof date parent at this point; returns true if a is being added */\nfunction _maybeAddInsertionPoint(node, parent, root) {\n let added;\n let insertionPointTag = root.getInsertionPointTag();\n if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE &&\n !node['__noInsertionPoint']) {\n let c$ = node.querySelectorAll(insertionPointTag);\n for (let i=0, n, np, na; (i (host of container needs distribution)\n/**\n * @param {Node} parent\n * @param {Node} node\n * @param {Node=} ref_node\n */\nexport function insertBefore(parent, node, ref_node) {\n if (ref_node) {\n let p = ref_node.__shady && ref_node.__shady.parentNode;\n if ((p !== undefined && p !== parent) ||\n (p === undefined && parentNode(ref_node) !== parent)) {\n throw Error(`Failed to execute 'insertBefore' on 'Node': The node ` +\n `before which the new node is to be inserted is not a child of this node.`);\n }\n }\n if (ref_node === node) {\n return node;\n }\n // remove node from its current position iff it's in a tree.\n if (node.nodeType !== Node.DOCUMENT_FRAGMENT_NODE) {\n let parent = node.__shady && node.__shady.parentNode;\n removeNodeFromParent(node, parent);\n }\n if (!addNode(parent, node, ref_node)) {\n if (ref_node) {\n // if ref_node is an insertion point replace with first distributed node\n let root = utils.ownerShadyRootForNode(ref_node);\n if (root) {\n ref_node = ref_node.localName === root.getInsertionPointTag() ?\n firstComposedNode(/** @type {!HTMLSlotElement} */(ref_node)) : ref_node;\n }\n }\n // if adding to a shadyRoot, add to host instead\n let container = utils.isShadyRoot(parent) ? /** @type {ShadowRoot} */(parent).host : parent;\n if (ref_node) {\n nativeMethods.insertBefore.call(container, node, ref_node);\n } else {\n nativeMethods.appendChild.call(container, node);\n }\n }\n _scheduleObserver(parent, node);\n return node;\n}\n\n/**\n Removes the given `node` from the element's `lightChildren`.\n This method also performs dom composition.\n*/\nexport function removeChild(parent, node) {\n if (node.parentNode !== parent) {\n throw Error('The node to be removed is not a child of this node: ' +\n node);\n }\n if (!removeNode(node)) {\n // if removing from a shadyRoot, remove form host instead\n let container = utils.isShadyRoot(parent) ?\n parent.host :\n parent;\n // not guaranteed to physically be in container; e.g.\n // undistributed nodes.\n let nativeParent = parentNode(node);\n if (container === nativeParent) {\n nativeMethods.removeChild.call(container, node);\n }\n }\n _scheduleObserver(parent, null, node);\n return node;\n}\n\nexport function cloneNode(node, deep) {\n if (node.localName == 'template') {\n return nativeMethods.cloneNode.call(node, deep);\n } else {\n let n = nativeMethods.cloneNode.call(node, false);\n if (deep) {\n let c$ = node.childNodes;\n for (let i=0, nc; i < c$.length; i++) {\n nc = c$[i].cloneNode(true);\n n.appendChild(nc);\n }\n }\n return n;\n }\n}\n\n// note: Though not technically correct, we fast path `importNode`\n// when called on a node not owned by the main document.\n// This allows, for example, elements that cannot\n// contain custom elements and are therefore not likely to contain shadowRoots\n// to cloned natively. This is a fairly significant performance win.\nexport function importNode(node, deep) {\n if (node.ownerDocument !== document) {\n return nativeMethods.importNode.call(document, node, deep);\n }\n let n = nativeMethods.importNode.call(document, node, false);\n if (deep) {\n let c$ = node.childNodes;\n for (let i=0, nc; i < c$.length; i++) {\n nc = importNode(c$[i], true);\n n.appendChild(nc);\n }\n }\n return n;\n}\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport * as utils from './utils'\n\nclass AsyncObserver {\n\n constructor() {\n this._scheduled = false;\n this.addedNodes = [];\n this.removedNodes = [];\n this.callbacks = new Set();\n }\n\n schedule() {\n if (!this._scheduled) {\n this._scheduled = true;\n utils.microtask(() => {\n this.flush();\n });\n }\n }\n\n flush() {\n if (this._scheduled) {\n this._scheduled = false;\n let mutations = this.takeRecords();\n if (mutations.length) {\n this.callbacks.forEach(function(cb) {\n cb(mutations);\n });\n }\n }\n }\n\n takeRecords() {\n if (this.addedNodes.length || this.removedNodes.length) {\n let mutations = [{\n addedNodes: this.addedNodes,\n removedNodes: this.removedNodes\n }];\n this.addedNodes = [];\n this.removedNodes = [];\n return mutations;\n }\n return [];\n }\n\n}\n\n// TODO(sorvell): consider instead polyfilling MutationObserver\n// directly so that users do not have to fork their code.\n// Supporting the entire api may be challenging: e.g. filtering out\n// removed nodes in the wrong scope and seeing non-distributing\n// subtree child mutations.\nexport let observeChildren = function(node, callback) {\n node.__shady = node.__shady || {};\n if (!node.__shady.observer) {\n node.__shady.observer = new AsyncObserver();\n }\n node.__shady.observer.callbacks.add(callback);\n let observer = node.__shady.observer;\n return {\n _callback: callback,\n _observer: observer,\n _node: node,\n takeRecords() {\n return observer.takeRecords()\n }\n };\n}\n\nexport let unobserveChildren = function(handle) {\n let observer = handle && handle._observer;\n if (observer) {\n observer.callbacks.delete(handle._callback);\n if (!observer.callbacks.size) {\n handle._node.__shady.observer = null;\n }\n }\n}\n\nexport function filterMutations(mutations, target) {\n /** @const {Node} */\n const targetRootNode = target.getRootNode();\n return mutations.map(function(mutation) {\n /** @const {boolean} */\n const mutationInScope = (targetRootNode === mutation.target.getRootNode());\n if (mutationInScope && mutation.addedNodes) {\n let nodes = Array.from(mutation.addedNodes).filter(function(n) {\n return (targetRootNode === n.getRootNode());\n });\n if (nodes.length) {\n mutation = Object.create(mutation);\n Object.defineProperty(mutation, 'addedNodes', {\n value: nodes,\n configurable: true\n });\n return mutation;\n }\n } else if (mutationInScope) {\n return mutation;\n }\n }).filter(function(m) { return m});\n}","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport * as utils from './utils'\nimport * as nativeMethods from './native-methods'\n\n// https://github.com/w3c/webcomponents/issues/513#issuecomment-224183937\nlet alwaysComposed = {\n 'blur': true,\n 'focus': true,\n 'focusin': true,\n 'focusout': true,\n 'click': true,\n 'dblclick': true,\n 'mousedown': true,\n 'mouseenter': true,\n 'mouseleave': true,\n 'mousemove': true,\n 'mouseout': true,\n 'mouseover': true,\n 'mouseup': true,\n 'wheel': true,\n 'beforeinput': true,\n 'input': true,\n 'keydown': true,\n 'keyup': true,\n 'compositionstart': true,\n 'compositionupdate': true,\n 'compositionend': true,\n 'touchstart': true,\n 'touchend': true,\n 'touchmove': true,\n 'touchcancel': true,\n 'pointerover': true,\n 'pointerenter': true,\n 'pointerdown': true,\n 'pointermove': true,\n 'pointerup': true,\n 'pointercancel': true,\n 'pointerout': true,\n 'pointerleave': true,\n 'gotpointercapture': true,\n 'lostpointercapture': true,\n 'dragstart': true,\n 'drag': true,\n 'dragenter': true,\n 'dragleave': true,\n 'dragover': true,\n 'drop': true,\n 'dragend': true,\n 'DOMActivate': true,\n 'DOMFocusIn': true,\n 'DOMFocusOut': true,\n 'keypress': true\n};\n\nfunction pathComposer(startNode, composed) {\n let composedPath = [];\n let current = startNode;\n let startRoot = startNode === window ? window : startNode.getRootNode();\n while (current) {\n composedPath.push(current);\n if (current.assignedSlot) {\n current = current.assignedSlot;\n } else if (current.nodeType === Node.DOCUMENT_FRAGMENT_NODE && current.host && (composed || current !== startRoot)) {\n current = current.host;\n } else {\n current = current.parentNode;\n }\n }\n // event composedPath includes window when startNode's ownerRoot is document\n if (composedPath[composedPath.length - 1] === document) {\n composedPath.push(window);\n }\n return composedPath;\n}\n\nfunction retarget(refNode, path) {\n if (!utils.isShadyRoot) {\n return refNode;\n }\n // If ANCESTOR's root is not a shadow root or ANCESTOR's root is BASE's\n // shadow-including inclusive ancestor, return ANCESTOR.\n let refNodePath = pathComposer(refNode, true);\n let p$ = path;\n for (let i=0, ancestor, lastRoot, root, rootIdx; i < p$.length; i++) {\n ancestor = p$[i];\n root = ancestor === window ? window : ancestor.getRootNode();\n if (root !== lastRoot) {\n rootIdx = refNodePath.indexOf(root);\n lastRoot = root;\n }\n if (!utils.isShadyRoot(root) || rootIdx > -1) {\n return ancestor;\n }\n }\n}\n\nlet eventMixin = {\n\n /**\n * @this {Event}\n */\n get composed() {\n // isTrusted may not exist in this browser, so just check if isTrusted is explicitly false\n if (this.isTrusted !== false && this.__composed === undefined) {\n this.__composed = alwaysComposed[this.type];\n }\n return this.__composed || false;\n },\n\n /**\n * @this {Event}\n */\n composedPath() {\n if (!this.__composedPath) {\n this.__composedPath = pathComposer(this['__target'], this.composed);\n }\n return this.__composedPath;\n },\n\n /**\n * @this {Event}\n */\n get target() {\n return retarget(this.currentTarget, this.composedPath());\n },\n\n // http://w3c.github.io/webcomponents/spec/shadow/#event-relatedtarget-retargeting\n /**\n * @this {Event}\n */\n get relatedTarget() {\n if (!this.__relatedTarget) {\n return null;\n }\n if (!this.__relatedTargetComposedPath) {\n this.__relatedTargetComposedPath = pathComposer(this.__relatedTarget, true);\n }\n // find the deepest node in relatedTarget composed path that is in the same root with the currentTarget\n return retarget(this.currentTarget, this.__relatedTargetComposedPath);\n },\n /**\n * @this {Event}\n */\n stopPropagation() {\n Event.prototype.stopPropagation.call(this);\n this.__propagationStopped = true;\n },\n /**\n * @this {Event}\n */\n stopImmediatePropagation() {\n Event.prototype.stopImmediatePropagation.call(this);\n this.__immediatePropagationStopped = true;\n this.__propagationStopped = true;\n }\n\n};\n\nfunction mixinComposedFlag(Base) {\n // NOTE: avoiding use of `class` here so that transpiled output does not\n // try to do `Base.call` with a dom construtor.\n let klazz = function(type, options) {\n let event = new Base(type, options);\n event.__composed = options && Boolean(options['composed']);\n return event;\n }\n // put constructor properties on subclass\n utils.mixin(klazz, Base);\n klazz.prototype = Base.prototype;\n return klazz;\n}\n\nlet nonBubblingEventsToRetarget = {\n 'focus': true,\n 'blur': true\n};\n\n\nfunction fireHandlers(event, node, phase) {\n let hs = node.__handlers && node.__handlers[event.type] &&\n node.__handlers[event.type][phase];\n if (hs) {\n for (let i = 0, fn; (fn = hs[i]); i++) {\n if (event.target === event.relatedTarget) {\n return;\n }\n fn.call(node, event);\n if (event.__immediatePropagationStopped) {\n return;\n }\n }\n }\n}\n\nfunction retargetNonBubblingEvent(e) {\n let path = e.composedPath();\n let node;\n // override `currentTarget` to let patched `target` calculate correctly\n Object.defineProperty(e, 'currentTarget', {\n get: function() {\n return node;\n },\n configurable: true\n });\n for (let i = path.length - 1; i >= 0; i--) {\n node = path[i];\n // capture phase fires all capture handlers\n fireHandlers(e, node, 'capture');\n if (e.__propagationStopped) {\n return;\n }\n }\n\n // set the event phase to `AT_TARGET` as in spec\n Object.defineProperty(e, 'eventPhase', {get() { return Event.AT_TARGET }});\n\n // the event only needs to be fired when owner roots change when iterating the event path\n // keep track of the last seen owner root\n let lastFiredRoot;\n for (let i = 0; i < path.length; i++) {\n node = path[i];\n if (i === 0 || (node.shadowRoot && node.shadowRoot === lastFiredRoot)) {\n fireHandlers(e, node, 'bubble');\n // don't bother with window, it doesn't have `getRootNode` and will be last in the path anyway\n if (node !== window) {\n lastFiredRoot = node.getRootNode();\n }\n if (e.__propagationStopped) {\n return;\n }\n }\n }\n}\n\nfunction listenerSettingsEqual(savedListener, node, type, capture, once, passive) {\n let {\n node: savedNode,\n type: savedType,\n capture: savedCapture,\n once: savedOnce,\n passive: savedPassive\n } = savedListener;\n return node === savedNode &&\n type === savedType &&\n capture === savedCapture &&\n once === savedOnce &&\n passive === savedPassive;\n}\n\nexport function findListener(wrappers, node, type, capture, once, passive) {\n for (let i = 0; i < wrappers.length; i++) {\n if (listenerSettingsEqual(wrappers[i], node, type, capture, once, passive)) {\n return i;\n }\n }\n return -1;\n}\n\n/**\n * @this {Event}\n */\nexport function addEventListener(type, fnOrObj, optionsOrCapture) {\n if (!fnOrObj) {\n return;\n }\n\n // The callback `fn` might be used for multiple nodes/events. Since we generate\n // a wrapper function, we need to keep track of it when we remove the listener.\n // It's more efficient to store the node/type/options information as Array in\n // `fn` itself rather than the node (we assume that the same callback is used\n // for few nodes at most, whereas a node will likely have many event listeners).\n // NOTE(valdrin) invoking external functions is costly, inline has better perf.\n let capture, once, passive;\n if (typeof optionsOrCapture === 'object') {\n capture = Boolean(optionsOrCapture.capture);\n once = Boolean(optionsOrCapture.once);\n passive = Boolean(optionsOrCapture.passive);\n } else {\n capture = Boolean(optionsOrCapture);\n once = false;\n passive = false;\n }\n // hack to let ShadyRoots have event listeners\n // event listener will be on host, but `currentTarget`\n // will be set to shadyroot for event listener\n let target = (optionsOrCapture && optionsOrCapture.__shadyTarget) || this;\n\n if (fnOrObj.__eventWrappers) {\n // Stop if the wrapper function has already been created.\n if (findListener(fnOrObj.__eventWrappers, target, type, capture, once, passive) > -1) {\n return;\n }\n } else {\n fnOrObj.__eventWrappers = [];\n }\n\n /**\n * @this {HTMLElement}\n */\n const wrapperFn = function(e) {\n // Support `once` option.\n if (once) {\n this.removeEventListener(type, fnOrObj, optionsOrCapture);\n }\n if (!e['__target']) {\n patchEvent(e);\n }\n let lastCurrentTargetDesc;\n if (target !== this) {\n // replace `currentTarget` to make `target` and `relatedTarget` correct for inside the shadowroot\n lastCurrentTargetDesc = Object.getOwnPropertyDescriptor(e, 'currentTarget');\n Object.defineProperty(e, 'currentTarget', {get() { return target }, configurable: true});\n }\n // There are two critera that should stop events from firing on this node\n // 1. the event is not composed and the current node is not in the same root as the target\n // 2. when bubbling, if after retargeting, relatedTarget and target point to the same node\n if (e.composed || e.composedPath().indexOf(target) > -1) {\n if (e.target === e.relatedTarget) {\n if (e.eventPhase === Event.BUBBLING_PHASE) {\n e.stopImmediatePropagation();\n }\n return;\n }\n // prevent non-bubbling events from triggering bubbling handlers on shadowroot, but only if not in capture phase\n if (e.eventPhase !== Event.CAPTURING_PHASE && !e.bubbles && e.target !== target) {\n return;\n }\n let ret = (typeof fnOrObj === 'object' && fnOrObj.handleEvent) ?\n fnOrObj.handleEvent(e) :\n fnOrObj.call(target, e);\n if (target !== this) {\n // replace the \"correct\" `currentTarget`\n if (lastCurrentTargetDesc) {\n Object.defineProperty(e, 'currentTarget', lastCurrentTargetDesc);\n lastCurrentTargetDesc = null;\n } else {\n delete e['currentTarget'];\n }\n }\n return ret;\n }\n };\n // Store the wrapper information.\n fnOrObj.__eventWrappers.push({\n node: this,\n type: type,\n capture: capture,\n once: once,\n passive: passive,\n wrapperFn: wrapperFn\n });\n\n if (nonBubblingEventsToRetarget[type]) {\n this.__handlers = this.__handlers || {};\n this.__handlers[type] = this.__handlers[type] ||\n {'capture': [], 'bubble': []};\n this.__handlers[type][capture ? 'capture' : 'bubble'].push(wrapperFn);\n } else {\n let ael = this instanceof Window ? nativeMethods.windowAddEventListener :\n nativeMethods.addEventListener;\n ael.call(this, type, wrapperFn, optionsOrCapture);\n }\n}\n\n/**\n * @this {Event}\n */\nexport function removeEventListener(type, fnOrObj, optionsOrCapture) {\n if (!fnOrObj) {\n return;\n }\n\n // NOTE(valdrin) invoking external functions is costly, inline has better perf.\n let capture, once, passive;\n if (typeof optionsOrCapture === 'object') {\n capture = Boolean(optionsOrCapture.capture);\n once = Boolean(optionsOrCapture.once);\n passive = Boolean(optionsOrCapture.passive);\n } else {\n capture = Boolean(optionsOrCapture);\n once = false;\n passive = false;\n }\n let target = (optionsOrCapture && optionsOrCapture.__shadyTarget) || this;\n // Search the wrapped function.\n let wrapperFn = undefined;\n if (fnOrObj.__eventWrappers) {\n let idx = findListener(fnOrObj.__eventWrappers, target, type, capture, once, passive);\n if (idx > -1) {\n wrapperFn = fnOrObj.__eventWrappers.splice(idx, 1)[0].wrapperFn;\n // Cleanup.\n if (!fnOrObj.__eventWrappers.length) {\n fnOrObj.__eventWrappers = undefined;\n }\n }\n }\n let rel = this instanceof Window ? nativeMethods.windowRemoveEventListener :\n nativeMethods.removeEventListener;\n rel.call(this, type, wrapperFn || fnOrObj, optionsOrCapture);\n if (wrapperFn && nonBubblingEventsToRetarget[type] &&\n this.__handlers && this.__handlers[type]) {\n const arr = this.__handlers[type][capture ? 'capture' : 'bubble'];\n const idx = arr.indexOf(wrapperFn);\n if (idx > -1) {\n arr.splice(idx, 1);\n }\n }\n}\n\nfunction activateFocusEventOverrides() {\n for (let ev in nonBubblingEventsToRetarget) {\n window.addEventListener(ev, function(e) {\n if (!e['__target']) {\n patchEvent(e);\n retargetNonBubblingEvent(e);\n }\n }, true);\n }\n}\n\nfunction patchEvent(event) {\n event['__target'] = event.target;\n event.__relatedTarget = event.relatedTarget;\n // patch event prototype if we can\n if (utils.settings.hasDescriptors) {\n utils.patchPrototype(event, eventMixin);\n // and fallback to patching instance\n } else {\n utils.extend(event, eventMixin);\n }\n}\n\nlet PatchedEvent = mixinComposedFlag(window.Event);\nlet PatchedCustomEvent = mixinComposedFlag(window.CustomEvent);\nlet PatchedMouseEvent = mixinComposedFlag(window.MouseEvent);\n\nexport function patchEvents() {\n window.Event = PatchedEvent;\n window.CustomEvent = PatchedCustomEvent;\n window.MouseEvent = PatchedMouseEvent;\n activateFocusEventOverrides();\n}\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport * as utils from './utils'\nimport {flush} from './flush'\nimport {dispatchEvent} from './native-methods'\nimport * as mutation from './logical-mutation'\nimport {ActiveElementAccessor, ShadowRootAccessor, patchAccessors} from './patch-accessors'\nimport {addEventListener, removeEventListener} from './patch-events'\nimport {attachShadow, ShadyRoot} from './attach-shadow'\n\nfunction getAssignedSlot(node) {\n mutation.renderRootNode(node);\n return node.__shady && node.__shady.assignedSlot || null;\n}\n\nlet windowMixin = {\n\n // NOTE: ensure these methods are bound to `window` so that `this` is correct\n // when called directly from global context without a receiver; e.g.\n // `addEventListener(...)`.\n addEventListener: addEventListener.bind(window),\n\n removeEventListener: removeEventListener.bind(window)\n\n};\n\nlet nodeMixin = {\n\n addEventListener: addEventListener,\n\n removeEventListener: removeEventListener,\n\n appendChild(node) {\n return mutation.insertBefore(this, node);\n },\n\n insertBefore(node, ref_node) {\n return mutation.insertBefore(this, node, ref_node);\n },\n\n removeChild(node) {\n return mutation.removeChild(this, node);\n },\n\n /**\n * @this {Node}\n */\n replaceChild(node, ref_node) {\n this.insertBefore(node, ref_node);\n this.removeChild(ref_node);\n return node;\n },\n\n /**\n * @this {Node}\n */\n cloneNode(deep) {\n return mutation.cloneNode(this, deep);\n },\n\n /**\n * @this {Node}\n */\n getRootNode(options) {\n return mutation.getRootNode(this, options);\n },\n\n /**\n * @this {Node}\n */\n get isConnected() {\n // Fast path for distributed nodes.\n const ownerDocument = this.ownerDocument;\n if (ownerDocument && ownerDocument.contains && ownerDocument.contains(this)) return true;\n const ownerDocumentElement = ownerDocument.documentElement;\n if (ownerDocumentElement && ownerDocumentElement.contains && ownerDocumentElement.contains(this)) return true;\n\n let node = this;\n while (node && !(node instanceof Document)) {\n node = node.parentNode || (node instanceof ShadyRoot ? /** @type {ShadowRoot} */(node).host : undefined);\n }\n return !!(node && node instanceof Document);\n },\n\n /**\n * @this {Node}\n */\n dispatchEvent(event) {\n flush();\n return dispatchEvent.call(this, event);\n }\n\n};\n\n// NOTE: For some reason `Text` redefines `assignedSlot`\nlet textMixin = {\n /**\n * @this {Text}\n */\n get assignedSlot() {\n return getAssignedSlot(this);\n }\n};\n\nlet fragmentMixin = {\n\n // TODO(sorvell): consider doing native QSA and filtering results.\n /**\n * @this {DocumentFragment}\n */\n querySelector(selector) {\n // match selector and halt on first result.\n let result = mutation.query(this, function(n) {\n return utils.matchesSelector(n, selector);\n }, function(n) {\n return Boolean(n);\n })[0];\n return result || null;\n },\n\n /**\n * @this {DocumentFragment}\n */\n querySelectorAll(selector) {\n return mutation.query(this, function(n) {\n return utils.matchesSelector(n, selector);\n });\n }\n\n};\n\nlet slotMixin = {\n\n /**\n * @this {HTMLSlotElement}\n */\n assignedNodes(options) {\n if (this.localName === 'slot') {\n mutation.renderRootNode(this);\n return this.__shady ?\n ((options && options.flatten ? this.__shady.distributedNodes :\n this.__shady.assignedNodes) || []) :\n [];\n }\n }\n\n};\n\nlet elementMixin = utils.extendAll({\n\n /**\n * @this {HTMLElement}\n */\n setAttribute(name, value) {\n mutation.setAttribute(this, name, value);\n },\n\n /**\n * @this {HTMLElement}\n */\n removeAttribute(name) {\n mutation.removeAttribute(this, name);\n },\n\n /**\n * @this {HTMLElement}\n */\n attachShadow(options) {\n return attachShadow(this, options);\n },\n\n /**\n * @this {HTMLElement}\n */\n get slot() {\n return this.getAttribute('slot');\n },\n\n /**\n * @this {HTMLElement}\n */\n set slot(value) {\n this.setAttribute('slot', value);\n },\n\n /**\n * @this {HTMLElement}\n */\n get assignedSlot() {\n return getAssignedSlot(this);\n }\n\n}, fragmentMixin, slotMixin);\n\nObject.defineProperties(elementMixin, ShadowRootAccessor);\n\nlet documentMixin = utils.extendAll({\n /**\n * @this {Document}\n */\n importNode(node, deep) {\n return mutation.importNode(node, deep);\n },\n\n /**\n * @this {Document}\n */\n getElementById(id) {\n return this.querySelector(`#${id}`);\n }\n\n}, fragmentMixin);\n\nObject.defineProperties(documentMixin, {\n '_activeElement': ActiveElementAccessor.activeElement\n});\n\nlet nativeBlur = HTMLElement.prototype.blur;\n\nlet htmlElementMixin = utils.extendAll({\n /**\n * @this {HTMLElement}\n */\n blur() {\n let root = this.shadowRoot;\n let shadowActive = root && root.activeElement;\n if (shadowActive) {\n shadowActive.blur();\n } else {\n nativeBlur.call(this);\n }\n }\n})\n\nfunction patchBuiltin(proto, obj) {\n let n$ = Object.getOwnPropertyNames(obj);\n for (let i=0; i < n$.length; i++) {\n let n = n$[i];\n let d = Object.getOwnPropertyDescriptor(obj, n);\n // NOTE: we prefer writing directly here because some browsers\n // have descriptors that are writable but not configurable (e.g.\n // `appendChild` on older browsers)\n if (d.value) {\n proto[n] = d.value;\n } else {\n Object.defineProperty(proto, n, d);\n }\n }\n}\n\n\n// Apply patches to builtins (e.g. Element.prototype). Some of these patches\n// can be done unconditionally (mostly methods like\n// `Element.prototype.appendChild`) and some can only be done when the browser\n// has proper descriptors on the builtin prototype\n// (e.g. `Element.prototype.firstChild`)`. When descriptors are not available,\n// elements are individually patched when needed (see e.g.\n// `patchInside/OutsideElementAccessors` in `patch-accessors.js`).\nexport function patchBuiltins() {\n let nativeHTMLElement =\n (window['customElements'] && window['customElements']['nativeHTMLElement']) ||\n HTMLElement;\n // These patches can always be done, for all supported browsers.\n patchBuiltin(window.Node.prototype, nodeMixin);\n patchBuiltin(window.Window.prototype, windowMixin);\n patchBuiltin(window.Text.prototype, textMixin);\n patchBuiltin(window.DocumentFragment.prototype, fragmentMixin);\n patchBuiltin(window.Element.prototype, elementMixin);\n patchBuiltin(window.Document.prototype, documentMixin);\n if (window.HTMLSlotElement) {\n patchBuiltin(window.HTMLSlotElement.prototype, slotMixin);\n }\n patchBuiltin(nativeHTMLElement.prototype, htmlElementMixin);\n // These patches can *only* be done\n // on browsers that have proper property descriptors on builtin prototypes.\n // This includes: IE11, Edge, Chrome >= 4?; Safari >= 10, Firefox\n // On older browsers (Chrome <= 4?, Safari 9), a per element patching\n // strategy is used for patching accessors.\n if (utils.settings.hasDescriptors) {\n patchAccessors(window.Node.prototype);\n patchAccessors(window.Text.prototype);\n patchAccessors(window.DocumentFragment.prototype);\n patchAccessors(window.Element.prototype);\n patchAccessors(nativeHTMLElement.prototype);\n patchAccessors(window.Document.prototype);\n if (window.HTMLSlotElement) {\n patchAccessors(window.HTMLSlotElement.prototype);\n }\n }\n}\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n/**\n * Patches elements that interacts with ShadyDOM\n * such that tree traversal and mutation apis act like they would under\n * ShadowDOM.\n *\n * This import enables seemless interaction with ShadyDOM powered\n * custom elements, enabling better interoperation with 3rd party code,\n * libraries, and frameworks that use DOM tree manipulation apis.\n */\n\n'use strict';\nimport * as utils from './utils'\nimport {flush, enqueue} from './flush'\nimport {observeChildren, unobserveChildren, filterMutations} from './observe-changes'\nimport * as nativeMethods from './native-methods'\nimport * as nativeTree from './native-tree'\nimport {patchBuiltins} from './patch-builtins'\nimport {patchEvents} from './patch-events'\nimport {ShadyRoot} from './attach-shadow'\n\nif (utils.settings.inUse) {\n let ShadyDOM = {\n // TODO(sorvell): remove when Polymer does not depend on this.\n 'inUse': utils.settings.inUse,\n // TODO(sorvell): remove when Polymer does not depend on this\n 'patch': (node) => node,\n 'isShadyRoot': utils.isShadyRoot,\n 'enqueue': enqueue,\n 'flush': flush,\n 'settings': utils.settings,\n 'filterMutations': filterMutations,\n 'observeChildren': observeChildren,\n 'unobserveChildren': unobserveChildren,\n 'nativeMethods': nativeMethods,\n 'nativeTree': nativeTree\n };\n\n window['ShadyDOM'] = ShadyDOM;\n\n // Apply patches to events...\n patchEvents();\n // Apply patches to builtins (e.g. Element.prototype) where applicable.\n patchBuiltins();\n\n window.ShadowRoot = ShadyRoot;\n}"]} \ No newline at end of file diff --git a/src/patch-builtins.js b/src/patch-builtins.js index bafa398..f668cde 100644 --- a/src/patch-builtins.js +++ b/src/patch-builtins.js @@ -25,9 +25,13 @@ function getAssignedSlot(node) { let windowMixin = { - addEventListener: addEventListener, + // NOTE: ensure these methods are bound to `window` so that `this` is correct + // when called directly from global context without a receiver; e.g. + // `addEventListener(...)`. + addEventListener: addEventListener.bind(window), + + removeEventListener: removeEventListener.bind(window) - removeEventListener: removeEventListener }; let nodeMixin = { diff --git a/src/patch-events.js b/src/patch-events.js index ab13a1b..69c6677 100644 --- a/src/patch-events.js +++ b/src/patch-events.js @@ -294,9 +294,7 @@ export function addEventListener(type, fnOrObj, optionsOrCapture) { // hack to let ShadyRoots have event listeners // event listener will be on host, but `currentTarget` // will be set to shadyroot for event listener - // NOTE: if no `this`, we assume this method was called on window. - let context = this || window; - let target = (optionsOrCapture && optionsOrCapture.__shadyTarget) || context; + let target = (optionsOrCapture && optionsOrCapture.__shadyTarget) || this; if (fnOrObj.__eventWrappers) { // Stop if the wrapper function has already been created. @@ -355,7 +353,7 @@ export function addEventListener(type, fnOrObj, optionsOrCapture) { }; // Store the wrapper information. fnOrObj.__eventWrappers.push({ - node: context, + node: this, type: type, capture: capture, once: once, @@ -364,14 +362,14 @@ export function addEventListener(type, fnOrObj, optionsOrCapture) { }); if (nonBubblingEventsToRetarget[type]) { - context.__handlers = context.__handlers || {}; - context.__handlers[type] = context.__handlers[type] || + this.__handlers = this.__handlers || {}; + this.__handlers[type] = this.__handlers[type] || {'capture': [], 'bubble': []}; - context.__handlers[type][capture ? 'capture' : 'bubble'].push(wrapperFn); + this.__handlers[type][capture ? 'capture' : 'bubble'].push(wrapperFn); } else { - let ael = context instanceof Window ? nativeMethods.windowAddEventListener : + let ael = this instanceof Window ? nativeMethods.windowAddEventListener : nativeMethods.addEventListener; - ael.call(context, type, wrapperFn, optionsOrCapture); + ael.call(this, type, wrapperFn, optionsOrCapture); } } @@ -394,9 +392,7 @@ export function removeEventListener(type, fnOrObj, optionsOrCapture) { once = false; passive = false; } - // NOTE: if no `this`, we assume this method was called on window. - let context = this || window; - let target = (optionsOrCapture && optionsOrCapture.__shadyTarget) || context; + let target = (optionsOrCapture && optionsOrCapture.__shadyTarget) || this; // Search the wrapped function. let wrapperFn = undefined; if (fnOrObj.__eventWrappers) { @@ -409,12 +405,12 @@ export function removeEventListener(type, fnOrObj, optionsOrCapture) { } } } - let rel = context instanceof Window ? nativeMethods.windowRemoveEventListener : + let rel = this instanceof Window ? nativeMethods.windowRemoveEventListener : nativeMethods.removeEventListener; - rel.call(context, type, wrapperFn || fnOrObj, optionsOrCapture); + rel.call(this, type, wrapperFn || fnOrObj, optionsOrCapture); if (wrapperFn && nonBubblingEventsToRetarget[type] && - context.__handlers && context.__handlers[type]) { - const arr = context.__handlers[type][capture ? 'capture' : 'bubble']; + this.__handlers && this.__handlers[type]) { + const arr = this.__handlers[type][capture ? 'capture' : 'bubble']; const idx = arr.indexOf(wrapperFn); if (idx > -1) { arr.splice(idx, 1);