diff --git a/scoping-shim.min.js b/scoping-shim.min.js index b20ee77..3fe38c5 100644 --- a/scoping-shim.min.js +++ b/scoping-shim.min.js @@ -33,7 +33,7 @@ function pb(a,b){var c={},e=[];A(a,function(a){a.f||R(a);var d=a.g||a.parsedSele function qb(a,b,c,e,d){c.f||R(c);if(c.f.i){b=F(b);a=b.is;b=b.u;b=a?M(a,b):"html";var f=c.parsedSelector,h=":host > *"===f||"html"===f,g=0===f.indexOf(":host")&&!h;"shady"===e&&(h=f===b+" > *."+b||-1!==f.indexOf("html"),g=!h&&0===f.indexOf(b));"shadow"===e&&(h=":host > *"===f||"html"===f,g=g&&!h);if(h||g)e=b,g&&(t&&!c.g&&(c.g=Ka(K,c,K.b,a?Ja+a:"",b)),e=c.g||b),d({M:e,K:g,S:h})}} function rb(a,b){var c={},e={},d=U,f=b&&b.__cssBuild;A(b,function(b){qb(d,a,b,f,function(d){kb.call(a.A||a,d.M)&&(d.K?S(b,c):S(b,e))})},null,!0);return{L:e,J:c}} function sb(a,b,c,e){var d=F(b),f=M(d.is,d.u),h=new RegExp("(?:^|[^.#[:])"+(b.extends?"\\"+f.slice(0,-1)+"\\]":f)+"($|[.:[\\s>+~])");d=O(b).j;var g=tb(d,e);return L(b,d,function(b){var d="";b.f||R(b);b.f.cssText&&(d=ob(a,b.f.cssText,c));b.cssText=d;if(!t&&!Aa(b)&&b.cssText){var k=d=b.cssText;null==b.C&&(b.C=wa.test(d));if(b.C)if(null==b.w){b.w=[];for(var q in g)k=g[q],k=k(d),d!==k&&(d=k,b.w.push(q))}else{for(q=0;q}\n */\nconst templateMap = {};\nexport default templateMap;\n",null,"/**\n@license\nCopyright (c) 2017 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/*\nExtremely simple css parser. Intended to be not more than what we need\nand definitely not necessarily correct =).\n*/\n\n'use strict';\n\n/** @unrestricted */\nclass StyleNode {\n constructor() {\n /** @type {number} */\n this['start'] = 0;\n /** @type {number} */\n this['end'] = 0;\n /** @type {StyleNode} */\n this['previous'] = null;\n /** @type {StyleNode} */\n this['parent'] = null;\n /** @type {Array} */\n this['rules'] = null;\n /** @type {string} */\n this['parsedCssText'] = '';\n /** @type {string} */\n this['cssText'] = '';\n /** @type {boolean} */\n this['atRule'] = false;\n /** @type {number} */\n this['type'] = 0;\n /** @type {string} */\n this['keyframesName'] = '';\n /** @type {string} */\n this['selector'] = '';\n /** @type {string} */\n this['parsedSelector'] = '';\n }\n}\n\nexport {StyleNode}\n\n// given a string of css, return a simple rule tree\n/**\n * @param {string} text\n * @return {StyleNode}\n */\nexport function parse(text) {\n text = clean(text);\n return parseCss(lex(text), text);\n}\n\n// remove stuff we don't care about that may hinder parsing\n/**\n * @param {string} cssText\n * @return {string}\n */\nfunction clean(cssText) {\n return cssText.replace(RX.comments, '').replace(RX.port, '');\n}\n\n// super simple {...} lexer that returns a node tree\n/**\n * @param {string} text\n * @return {StyleNode}\n */\nfunction lex(text) {\n let root = new StyleNode();\n root['start'] = 0;\n root['end'] = text.length\n let n = root;\n for (let i = 0, l = text.length; i < l; i++) {\n if (text[i] === OPEN_BRACE) {\n if (!n['rules']) {\n n['rules'] = [];\n }\n let p = n;\n let previous = p['rules'][p['rules'].length - 1] || null;\n n = new StyleNode();\n n['start'] = i + 1;\n n['parent'] = p;\n n['previous'] = previous;\n p['rules'].push(n);\n } else if (text[i] === CLOSE_BRACE) {\n n['end'] = i + 1;\n n = n['parent'] || root;\n }\n }\n return root;\n}\n\n// add selectors/cssText to node tree\n/**\n * @param {StyleNode} node\n * @param {string} text\n * @return {StyleNode}\n */\nfunction parseCss(node, text) {\n let t = text.substring(node['start'], node['end'] - 1);\n node['parsedCssText'] = node['cssText'] = t.trim();\n if (node['parent']) {\n let ss = node['previous'] ? node['previous']['end'] : node['parent']['start'];\n t = text.substring(ss, node['start'] - 1);\n t = _expandUnicodeEscapes(t);\n t = t.replace(RX.multipleSpaces, ' ');\n // TODO(sorvell): ad hoc; make selector include only after last ;\n // helps with mixin syntax\n t = t.substring(t.lastIndexOf(';') + 1);\n let s = node['parsedSelector'] = node['selector'] = t.trim();\n node['atRule'] = (s.indexOf(AT_START) === 0);\n // note, support a subset of rule types...\n if (node['atRule']) {\n if (s.indexOf(MEDIA_START) === 0) {\n node['type'] = types.MEDIA_RULE;\n } else if (s.match(RX.keyframesRule)) {\n node['type'] = types.KEYFRAMES_RULE;\n node['keyframesName'] =\n node['selector'].split(RX.multipleSpaces).pop();\n }\n } else {\n if (s.indexOf(VAR_START) === 0) {\n node['type'] = types.MIXIN_RULE;\n } else {\n node['type'] = types.STYLE_RULE;\n }\n }\n }\n let r$ = node['rules'];\n if (r$) {\n for (let i = 0, l = r$.length, r;\n (i < l) && (r = r$[i]); i++) {\n parseCss(r, text);\n }\n }\n return node;\n}\n\n/**\n * conversion of sort unicode escapes with spaces like `\\33 ` (and longer) into\n * expanded form that doesn't require trailing space `\\000033`\n * @param {string} s\n * @return {string}\n */\nfunction _expandUnicodeEscapes(s) {\n return s.replace(/\\\\([0-9a-f]{1,6})\\s/gi, function() {\n let code = arguments[1],\n repeat = 6 - code.length;\n while (repeat--) {\n code = '0' + code;\n }\n return '\\\\' + code;\n });\n}\n\n/**\n * stringify parsed css.\n * @param {StyleNode} node\n * @param {boolean=} preserveProperties\n * @param {string=} text\n * @return {string}\n */\nexport function stringify(node, preserveProperties, text = '') {\n // calc rule cssText\n let cssText = '';\n if (node['cssText'] || node['rules']) {\n let r$ = node['rules'];\n if (r$ && !_hasMixinRules(r$)) {\n for (let i = 0, l = r$.length, r;\n (i < l) && (r = r$[i]); i++) {\n cssText = stringify(r, preserveProperties, cssText);\n }\n } else {\n cssText = preserveProperties ? node['cssText'] :\n removeCustomProps(node['cssText']);\n cssText = cssText.trim();\n if (cssText) {\n cssText = ' ' + cssText + '\\n';\n }\n }\n }\n // emit rule if there is cssText\n if (cssText) {\n if (node['selector']) {\n text += node['selector'] + ' ' + OPEN_BRACE + '\\n';\n }\n text += cssText;\n if (node['selector']) {\n text += CLOSE_BRACE + '\\n\\n';\n }\n }\n return text;\n}\n\n/**\n * @param {Array} rules\n * @return {boolean}\n */\nfunction _hasMixinRules(rules) {\n let r = rules[0];\n return Boolean(r) && Boolean(r['selector']) && r['selector'].indexOf(VAR_START) === 0;\n}\n\n/**\n * @param {string} cssText\n * @return {string}\n */\nfunction removeCustomProps(cssText) {\n cssText = removeCustomPropAssignment(cssText);\n return removeCustomPropApply(cssText);\n}\n\n/**\n * @param {string} cssText\n * @return {string}\n */\nexport function removeCustomPropAssignment(cssText) {\n return cssText\n .replace(RX.customProp, '')\n .replace(RX.mixinProp, '');\n}\n\n/**\n * @param {string} cssText\n * @return {string}\n */\nfunction removeCustomPropApply(cssText) {\n return cssText\n .replace(RX.mixinApply, '')\n .replace(RX.varApply, '');\n}\n\n/** @enum {number} */\nexport const types = {\n STYLE_RULE: 1,\n KEYFRAMES_RULE: 7,\n MEDIA_RULE: 4,\n MIXIN_RULE: 1000\n}\n\nconst OPEN_BRACE = '{';\nconst CLOSE_BRACE = '}';\n\n// helper regexp's\nconst RX = {\n comments: /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//gim,\n port: /@import[^;]*;/gim,\n customProp: /(?:^[^;\\-\\s}]+)?--[^;{}]*?:[^{};]*?(?:[;\\n]|$)/gim,\n mixinProp: /(?:^[^;\\-\\s}]+)?--[^;{}]*?:[^{};]*?{[^}]*?}(?:[;\\n]|$)?/gim,\n mixinApply: /@apply\\s*\\(?[^);]*\\)?\\s*(?:[;\\n]|$)?/gim,\n varApply: /[^;:]*?:[^;]*?var\\([^;]*\\)(?:[;\\n]|$)?/gim,\n keyframesRule: /^@[^\\s]*keyframes/,\n multipleSpaces: /\\s+/g\n}\n\nconst VAR_START = '--';\nconst MEDIA_START = '@media';\nconst AT_START = '@';\n","/**\n@license\nCopyright (c) 2017 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';\nimport templateMap from './template-map.js';\nimport {StyleNode} from './css-parse.js'; // eslint-disable-line no-unused-vars\n\n/*\n * Utilities for handling invalidating apply-shim mixins for a given template.\n *\n * The invalidation strategy involves keeping track of the \"current\" version of a template's mixins, and updating that count when a mixin is invalidated.\n * The template\n */\n\n/** @const {string} */\nconst CURRENT_VERSION = '_applyShimCurrentVersion';\n\n/** @const {string} */\nconst NEXT_VERSION = '_applyShimNextVersion';\n\n/** @const {string} */\nconst VALIDATING_VERSION = '_applyShimValidatingVersion';\n\n/**\n * @const {Promise}\n */\nconst promise = Promise.resolve();\n\n/**\n * @param {string} elementName\n */\nexport function invalidate(elementName){\n let template = templateMap[elementName];\n if (template) {\n invalidateTemplate(template);\n }\n}\n\n/**\n * This function can be called multiple times to mark a template invalid\n * and signal that the style inside must be regenerated.\n *\n * Use `startValidatingTemplate` to begin an asynchronous validation cycle.\n * During that cycle, call `templateIsValidating` to see if the template must\n * be revalidated\n * @param {HTMLTemplateElement} template\n */\nexport function invalidateTemplate(template) {\n // default the current version to 0\n template[CURRENT_VERSION] = template[CURRENT_VERSION] || 0;\n // ensure the \"validating for\" flag exists\n template[VALIDATING_VERSION] = template[VALIDATING_VERSION] || 0;\n // increment the next version\n template[NEXT_VERSION] = (template[NEXT_VERSION] || 0) + 1;\n}\n\n/**\n * @param {string} elementName\n * @return {boolean}\n */\nexport function isValid(elementName) {\n let template = templateMap[elementName];\n if (template) {\n return templateIsValid(template);\n }\n return true;\n}\n\n/**\n * @param {HTMLTemplateElement} template\n * @return {boolean}\n */\nexport function templateIsValid(template) {\n return template[CURRENT_VERSION] === template[NEXT_VERSION];\n}\n\n/**\n * @param {string} elementName\n * @return {boolean}\n */\nexport function isValidating(elementName) {\n let template = templateMap[elementName];\n if (template) {\n return templateIsValidating(template);\n }\n return false;\n}\n\n/**\n * Returns true if the template is currently invalid and `startValidating` has been called since the last invalidation.\n * If false, the template must be validated.\n * @param {HTMLTemplateElement} template\n * @return {boolean}\n */\nexport function templateIsValidating(template) {\n return !templateIsValid(template) && template[VALIDATING_VERSION] === template[NEXT_VERSION];\n}\n\n/**\n * the template is marked as `validating` for one microtask so that all instances\n * found in the tree crawl of `applyStyle` will update themselves,\n * but the template will only be updated once.\n * @param {string} elementName\n*/\nexport function startValidating(elementName) {\n let template = templateMap[elementName];\n startValidatingTemplate(template);\n}\n\n/**\n * Begin an asynchronous invalidation cycle.\n * This should be called after every validation of a template\n *\n * After one microtask, the template will be marked as valid until the next call to `invalidateTemplate`\n * @param {HTMLTemplateElement} template\n */\nexport function startValidatingTemplate(template) {\n // remember that the current \"next version\" is the reason for this validation cycle\n template[VALIDATING_VERSION] = template[NEXT_VERSION];\n // however, there only needs to be one async task to clear the counters\n if (!template._validating) {\n template._validating = true;\n promise.then(function() {\n // sync the current version to let future invalidations cause a refresh cycle\n template[CURRENT_VERSION] = template[NEXT_VERSION];\n template._validating = false;\n });\n }\n}\n\n/**\n * @return {boolean}\n */\nexport function elementsAreInvalid() {\n for (let elementName in templateMap) {\n let template = templateMap[elementName];\n if (!templateIsValid(template)) {\n return true;\n }\n }\n return false;\n}","/**\n@license\nCopyright (c) 2017 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 nativeShadow = !(window['ShadyDOM'] && window['ShadyDOM']['inUse']);\nexport let nativeCssVariables;\n\n/**\n * @param {(ShadyCSSOptions | ShadyCSSInterface)=} settings\n */\nfunction calcCssVariables(settings) {\n if (settings && settings['shimcssproperties']) {\n nativeCssVariables = false;\n } else {\n // chrome 49 has semi-working css vars, check if box-shadow works\n // safari 9.1 has a recalc bug: https://bugs.webkit.org/show_bug.cgi?id=155782\n // However, shim css custom properties are only supported with ShadyDOM enabled,\n // so fall back on native if we do not detect ShadyDOM\n // Edge 15: custom properties used in ::before and ::after will also be used in the parent element\n // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/12414257/\n nativeCssVariables = nativeShadow || Boolean(!navigator.userAgent.match(/AppleWebKit\\/601|Edge\\/15/) &&\n window.CSS && CSS.supports && CSS.supports('box-shadow', '0 0 0 var(--foo)'));\n }\n}\n\nif (window.ShadyCSS && window.ShadyCSS.nativeCss !== undefined) {\n nativeCssVariables = window.ShadyCSS.nativeCss;\n} else if (window.ShadyCSS) {\n calcCssVariables(window.ShadyCSS);\n // reset window variable to let ShadyCSS API take its place\n window.ShadyCSS = undefined;\n} else {\n calcCssVariables(window['WebComponents'] && window['WebComponents']['flags']);\n}","/**\n@license\nCopyright (c) 2017 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\nexport const VAR_ASSIGN = /(?:^|[;\\s{]\\s*)(--[\\w-]*?)\\s*:\\s*(?:((?:'(?:\\\\'|.)*?'|\"(?:\\\\\"|.)*?\"|\\([^)]*?\\)|[^};{])+)|\\{([^}]*)\\}(?:(?=[;\\s}])|$))/gi;\nexport const MIXIN_MATCH = /(?:^|\\W+)@apply\\s*\\(?([^);\\n]*)\\)?/gi;\nexport const VAR_CONSUMED = /(--[\\w-]+)\\s*([:,;)]|$)/gi;\nexport const ANIMATION_MATCH = /(animation\\s*:)|(animation-name\\s*:)/;\nexport const MEDIA_MATCH = /@media\\s(.*)/;\nexport const IS_VAR = /^--/;\nexport const BRACKETED = /\\{[^}]*\\}/g;\nexport const HOST_PREFIX = '(?:^|[^.#[:])';\nexport const HOST_SUFFIX = '($|[.:[\\\\s>+~])';\n","/**\n@license\nCopyright (c) 2017 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/** @type {!Set} */\nconst styleTextSet = new Set();\n\nexport const scopingAttribute = 'shady-unscoped';\n\n/**\n * Add a specifically-marked style to the document directly, and only one copy of that style.\n *\n * @param {!HTMLStyleElement} style\n * @return {undefined}\n */\nexport function processUnscopedStyle(style) {\n const text = style.textContent;\n if (!styleTextSet.has(text)) {\n styleTextSet.add(text);\n const newStyle = style.cloneNode(true);\n document.head.appendChild(newStyle);\n }\n}\n\n/**\n * Check if a style is supposed to be unscoped\n * @param {!HTMLStyleElement} style\n * @return {boolean} true if the style has the unscoping attribute\n */\nexport function isUnscopedStyle(style) {\n return style.hasAttribute(scopingAttribute);\n}","/**\n@license\nCopyright (c) 2017 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 {nativeShadow, nativeCssVariables} from './style-settings.js';\nimport {parse, stringify, types, StyleNode} from './css-parse.js'; // eslint-disable-line no-unused-vars\nimport {MEDIA_MATCH} from './common-regex.js';\nimport {processUnscopedStyle, isUnscopedStyle} from './unscoped-style-handler.js';\n\n/**\n * @param {string|StyleNode} rules\n * @param {function(StyleNode)=} callback\n * @return {string}\n */\nexport function toCssText (rules, callback) {\n if (!rules) {\n return '';\n }\n if (typeof rules === 'string') {\n rules = parse(rules);\n }\n if (callback) {\n forEachRule(rules, callback);\n }\n return stringify(rules, nativeCssVariables);\n}\n\n/**\n * @param {HTMLStyleElement} style\n * @return {StyleNode}\n */\nexport function rulesForStyle(style) {\n if (!style['__cssRules'] && style.textContent) {\n style['__cssRules'] = parse(style.textContent);\n }\n return style['__cssRules'] || null;\n}\n\n// Tests if a rule is a keyframes selector, which looks almost exactly\n// like a normal selector but is not (it has nothing to do with scoping\n// for example).\n/**\n * @param {StyleNode} rule\n * @return {boolean}\n */\nexport function isKeyframesSelector(rule) {\n return Boolean(rule['parent']) &&\n rule['parent']['type'] === types.KEYFRAMES_RULE;\n}\n\n/**\n * @param {StyleNode} node\n * @param {Function=} styleRuleCallback\n * @param {Function=} keyframesRuleCallback\n * @param {boolean=} onlyActiveRules\n */\nexport function forEachRule(node, styleRuleCallback, keyframesRuleCallback, onlyActiveRules) {\n if (!node) {\n return;\n }\n let skipRules = false;\n let type = node['type'];\n if (onlyActiveRules) {\n if (type === types.MEDIA_RULE) {\n let matchMedia = node['selector'].match(MEDIA_MATCH);\n if (matchMedia) {\n // if rule is a non matching @media rule, skip subrules\n if (!window.matchMedia(matchMedia[1]).matches) {\n skipRules = true;\n }\n }\n }\n }\n if (type === types.STYLE_RULE) {\n styleRuleCallback(node);\n } else if (keyframesRuleCallback &&\n type === types.KEYFRAMES_RULE) {\n keyframesRuleCallback(node);\n } else if (type === types.MIXIN_RULE) {\n skipRules = true;\n }\n let r$ = node['rules'];\n if (r$ && !skipRules) {\n for (let i=0, l=r$.length, r; (i`\n */\n if (localName) {\n if (localName.indexOf('-') > -1) {\n is = localName;\n } else {\n typeExtension = localName;\n is = (element.getAttribute && element.getAttribute('is')) || '';\n }\n } else {\n is = /** @type {?} */(element).is;\n typeExtension = /** @type {?} */(element).extends;\n }\n return {is, typeExtension};\n}\n\n/**\n * @param {Element|DocumentFragment} element\n * @return {string}\n */\nexport function gatherStyleText(element) {\n /** @type {!Array} */\n const styleTextParts = [];\n const styles = /** @type {!NodeList} */(element.querySelectorAll('style'));\n for (let i = 0; i < styles.length; i++) {\n const style = styles[i];\n if (isUnscopedStyle(style)) {\n if (!nativeShadow) {\n processUnscopedStyle(style);\n style.parentNode.removeChild(style);\n }\n } else {\n styleTextParts.push(style.textContent);\n style.parentNode.removeChild(style);\n }\n }\n return styleTextParts.join('').trim();\n}","/**\n@license\nCopyright (c) 2017 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/** @type {Promise} */\nlet readyPromise = null;\n\n/** @type {?function(?function())} */\nlet whenReady = window['HTMLImports'] && window['HTMLImports']['whenReady'] || null;\n\n/** @type {function()} */\nlet resolveFn;\n\n/**\n * @param {?function()} callback\n */\nexport default function documentWait(callback) {\n requestAnimationFrame(function() {\n if (whenReady) {\n whenReady(callback)\n } else {\n if (!readyPromise) {\n readyPromise = new Promise((resolve) => {resolveFn = resolve});\n if (document.readyState === 'complete') {\n resolveFn();\n } else {\n document.addEventListener('readystatechange', () => {\n if (document.readyState === 'complete') {\n resolveFn();\n }\n });\n }\n }\n readyPromise.then(function(){ callback && callback(); });\n }\n });\n}\n","/**\n@license\nCopyright (c) 2017 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 {StyleNode} from './css-parse.js'; // eslint-disable-line no-unused-vars\nimport * as StyleUtil from './style-util.js';\nimport {nativeShadow} from './style-settings.js';\n\n/* Transforms ShadowDOM styling into ShadyDOM styling\n\n* scoping:\n\n * elements in scope get scoping selector class=\"x-foo-scope\"\n * selectors re-written as follows:\n\n div button -> div.x-foo-scope button.x-foo-scope\n\n* :host -> scopeName\n\n* :host(...) -> scopeName...\n\n* ::slotted(...) -> scopeName > ...\n\n* ...:dir(ltr|rtl) -> [dir=\"ltr|rtl\"] ..., ...[dir=\"ltr|rtl\"]\n\n* :host(:dir[rtl]) -> scopeName:dir(rtl) -> [dir=\"rtl\"] scopeName, scopeName[dir=\"rtl\"]\n\n*/\nconst SCOPE_NAME = 'style-scope';\n\nclass StyleTransformer {\n get SCOPE_NAME() {\n return SCOPE_NAME;\n }\n // Given a node and scope name, add a scoping class to each node\n // in the tree. This facilitates transforming css into scoped rules.\n dom(node, scope, shouldRemoveScope) {\n // one time optimization to skip scoping...\n if (node['__styleScoped']) {\n node['__styleScoped'] = null;\n } else {\n this._transformDom(node, scope || '', shouldRemoveScope);\n }\n }\n\n _transformDom(node, selector, shouldRemoveScope) {\n if (node.nodeType === Node.ELEMENT_NODE) {\n this.element(node, selector, shouldRemoveScope);\n }\n let c$ = (node.localName === 'template') ?\n (node.content || node._content).childNodes :\n node.children || node.childNodes;\n if (c$) {\n for (let i=0; i {\n if (inside.indexOf('+') > -1) {\n inside = inside.replace(/\\+/g, '___');\n } else if (inside.indexOf('___') > -1) {\n inside = inside.replace(/___/g, '+');\n }\n return `:${type}(${inside})`;\n });\n }\n\n/**\n * @param {string} selector\n * @param {string} scope\n * @param {string=} hostScope\n */\n _transformComplexSelector(selector, scope, hostScope) {\n let stop = false;\n selector = selector.trim();\n // Remove spaces inside of selectors like `:nth-of-type` because it confuses SIMPLE_SELECTOR_SEP\n let isNth = NTH.test(selector);\n if (isNth) {\n selector = selector.replace(NTH, (m, type, inner) => `:${type}(${inner.replace(/\\s/g, '')})`)\n selector = this._twiddleNthPlus(selector);\n }\n selector = selector.replace(SLOTTED_START, `${HOST} $1`);\n selector = selector.replace(SIMPLE_SELECTOR_SEP, (m, c, s) => {\n if (!stop) {\n let info = this._transformCompoundSelector(s, c, scope, hostScope);\n stop = stop || info.stop;\n c = info.combinator;\n s = info.value;\n }\n return c + s;\n });\n if (isNth) {\n selector = this._twiddleNthPlus(selector);\n }\n return selector;\n }\n\n _transformCompoundSelector(selector, combinator, scope, hostScope) {\n // replace :host with host scoping class\n let slottedIndex = selector.indexOf(SLOTTED);\n if (selector.indexOf(HOST) >= 0) {\n selector = this._transformHostSelector(selector, hostScope);\n // replace other selectors with scoping class\n } else if (slottedIndex !== 0) {\n selector = scope ? this._transformSimpleSelector(selector, scope) :\n selector;\n }\n // mark ::slotted() scope jump to replace with descendant selector + arg\n // also ignore left-side combinator\n let slotted = false;\n if (slottedIndex >= 0) {\n combinator = '';\n slotted = true;\n }\n // process scope jumping selectors up to the scope jump and then stop\n let stop;\n if (slotted) {\n stop = true;\n if (slotted) {\n // .zonk ::slotted(.foo) -> .zonk.scope > .foo\n selector = selector.replace(SLOTTED_PAREN, (m, paren) => ` > ${paren}`);\n }\n }\n selector = selector.replace(DIR_PAREN, (m, before, dir) =>\n `[dir=\"${dir}\"] ${before}, ${before}[dir=\"${dir}\"]`);\n return {value: selector, combinator, stop};\n }\n\n _transformSimpleSelector(selector, scope) {\n let p$ = selector.split(PSEUDO_PREFIX);\n p$[0] += scope;\n return p$.join(PSEUDO_PREFIX);\n }\n\n // :host(...) -> scopeName...\n _transformHostSelector(selector, hostScope) {\n let m = selector.match(HOST_PAREN);\n let paren = m && m[2].trim() || '';\n if (paren) {\n if (!paren[0].match(SIMPLE_SELECTOR_PREFIX)) {\n // paren starts with a type selector\n let typeSelector = paren.split(SIMPLE_SELECTOR_PREFIX)[0];\n // if the type selector is our hostScope then avoid pre-pending it\n if (typeSelector === hostScope) {\n return paren;\n // otherwise, this selector should not match in this scope so\n // output a bogus selector.\n } else {\n return SELECTOR_NO_MATCH;\n }\n } else {\n // make sure to do a replace here to catch selectors like:\n // `:host(.foo)::before`\n return selector.replace(HOST_PAREN, function(m, host, paren) {\n return hostScope + paren;\n });\n }\n // if no paren, do a straight :host replacement.\n // TODO(sorvell): this should not strictly be necessary but\n // it's needed to maintain support for `:host[foo]` type selectors\n // which have been improperly used under Shady DOM. This should be\n // deprecated.\n } else {\n return selector.replace(HOST, hostScope);\n }\n }\n\n /**\n * @param {StyleNode} rule\n */\n documentRule(rule) {\n // reset selector in case this is redone.\n rule['selector'] = rule['parsedSelector'];\n this.normalizeRootSelector(rule);\n this._transformRule(rule, this._transformDocumentSelector);\n }\n\n /**\n * @param {StyleNode} rule\n */\n normalizeRootSelector(rule) {\n if (rule['selector'] === ROOT) {\n rule['selector'] = 'html';\n }\n }\n\n/**\n * @param {string} selector\n */\n _transformDocumentSelector(selector) {\n return selector.match(SLOTTED) ?\n this._transformComplexSelector(selector, SCOPE_DOC_SELECTOR) :\n this._transformSimpleSelector(selector.trim(), SCOPE_DOC_SELECTOR);\n }\n}\n\nlet NTH = /:(nth[-\\w]+)\\(([^)]+)\\)/;\nlet SCOPE_DOC_SELECTOR = `:not(.${SCOPE_NAME})`;\nlet COMPLEX_SELECTOR_SEP = ',';\nlet SIMPLE_SELECTOR_SEP = /(^|[\\s>+~]+)((?:\\[.+?\\]|[^\\s>+~=[])+)/g;\nlet SIMPLE_SELECTOR_PREFIX = /[[.:#*]/;\nlet HOST = ':host';\nlet ROOT = ':root';\nlet SLOTTED = '::slotted';\nlet SLOTTED_START = new RegExp(`^(${SLOTTED})`);\n// NOTE: this supports 1 nested () pair for things like\n// :host(:not([selected]), more general support requires\n// parsing which seems like overkill\nlet HOST_PAREN = /(:host)(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))/;\n// similar to HOST_PAREN\nlet SLOTTED_PAREN = /(?:::slotted)(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))/;\nlet DIR_PAREN = /(.*):dir\\((?:(ltr|rtl))\\)/;\nlet CSS_CLASS_PREFIX = '.';\nlet PSEUDO_PREFIX = ':';\nlet CLASS = 'class';\nlet SELECTOR_NO_MATCH = 'should_not_match';\n\nexport default new StyleTransformer()","/**\n@license\nCopyright (c) 2017 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 {nativeShadow} from './style-settings.js';\nimport StyleTransformer from './style-transformer.js';\nimport {getIsExtends} from './style-util.js';\n\nexport let flush = function() {};\n\n/**\n * @param {HTMLElement} element\n * @return {!Array}\n */\nfunction getClasses(element) {\n let classes = [];\n if (element.classList) {\n classes = Array.from(element.classList);\n } else if (element instanceof window['SVGElement'] && element.hasAttribute('class')) {\n classes = element.getAttribute('class').split(/\\s+/);\n }\n return classes;\n}\n\n/**\n * @param {HTMLElement} element\n * @return {string}\n */\nfunction getCurrentScope(element) {\n let classes = getClasses(element);\n let idx = classes.indexOf(StyleTransformer.SCOPE_NAME);\n if (idx > -1) {\n return classes[idx + 1];\n }\n return '';\n}\n\n/**\n * @param {Array|null} mxns\n */\nfunction handler(mxns) {\n for (let x=0; x < mxns.length; x++) {\n let mxn = mxns[x];\n if (mxn.target === document.documentElement ||\n mxn.target === document.head) {\n continue;\n }\n for (let i=0; i < mxn.addedNodes.length; i++) {\n let n = mxn.addedNodes[i];\n if (n.nodeType !== Node.ELEMENT_NODE) {\n continue;\n }\n n = /** @type {HTMLElement} */(n); // eslint-disable-line no-self-assign\n let root = n.getRootNode();\n let currentScope = getCurrentScope(n);\n // node was scoped, but now is in document\n if (currentScope && root === n.ownerDocument) {\n StyleTransformer.dom(n, currentScope, true);\n } else if (root.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n let newScope;\n let host = /** @type {ShadowRoot} */(root).host;\n // element may no longer be in a shadowroot\n if (!host) {\n continue;\n }\n newScope = getIsExtends(host).is;\n if (currentScope === newScope) {\n // make sure all the subtree elements are scoped correctly\n let unscoped = window['ShadyDOM']['nativeMethods']['querySelectorAll'].call(\n n, `:not(.${StyleTransformer.SCOPE_NAME})`);\n for (let j = 0; j < unscoped.length; j++) {\n StyleTransformer.element(unscoped[j], currentScope);\n }\n continue;\n }\n if (currentScope) {\n StyleTransformer.dom(n, currentScope, true);\n }\n StyleTransformer.dom(n, newScope);\n }\n }\n }\n}\n\nif (!nativeShadow) {\n let observer = new MutationObserver(handler);\n let start = (node) => {\n observer.observe(node, {childList: true, subtree: true});\n }\n let nativeCustomElements = (window['customElements'] &&\n !window['customElements']['polyfillWrapFlushCallback']);\n // need to start immediately with native custom elements\n // TODO(dfreedm): with polyfilled HTMLImports and native custom elements\n // excessive mutations may be observed; this can be optimized via cooperation\n // with the HTMLImports polyfill.\n if (nativeCustomElements) {\n start(document);\n } else {\n let delayedStart = () => {\n start(document.body);\n }\n // use polyfill timing if it's available\n if (window['HTMLImports']) {\n window['HTMLImports']['whenReady'](delayedStart);\n // otherwise push beyond native imports being ready\n // which requires RAF + readystate interactive.\n } else {\n requestAnimationFrame(function() {\n if (document.readyState === 'loading') {\n let listener = function() {\n delayedStart();\n document.removeEventListener('readystatechange', listener);\n }\n document.addEventListener('readystatechange', listener);\n } else {\n delayedStart();\n }\n });\n }\n }\n\n flush = function() {\n handler(observer.takeRecords());\n }\n}\n","/**\n@license\nCopyright (c) 2017 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 {StyleNode} from './css-parse.js'; // eslint-disable-line no-unused-vars\n\n/** @const {string} */\nconst infoKey = '__styleInfo';\n\nexport default class StyleInfo {\n /**\n * @param {Element} node\n * @return {StyleInfo}\n */\n static get(node) {\n if (node) {\n return node[infoKey];\n } else {\n return null;\n }\n }\n /**\n * @param {!Element} node\n * @param {StyleInfo} styleInfo\n * @return {StyleInfo}\n */\n static set(node, styleInfo) {\n node[infoKey] = styleInfo;\n return styleInfo;\n }\n /**\n * @param {StyleNode} ast\n * @param {Node=} placeholder\n * @param {Array=} ownStylePropertyNames\n * @param {string=} elementName\n * @param {string=} typeExtension\n * @param {string=} cssBuild\n */\n constructor(ast, placeholder, ownStylePropertyNames, elementName, typeExtension, cssBuild) {\n /** @type {StyleNode} */\n this.styleRules = ast || null;\n /** @type {Node} */\n this.placeholder = placeholder || null;\n /** @type {!Array} */\n this.ownStylePropertyNames = ownStylePropertyNames || [];\n /** @type {Array} */\n this.overrideStyleProperties = null;\n /** @type {string} */\n this.elementName = elementName || '';\n /** @type {string} */\n this.cssBuild = cssBuild || '';\n /** @type {string} */\n this.typeExtension = typeExtension || '';\n /** @type {Object} */\n this.styleProperties = null;\n /** @type {?string} */\n this.scopeSelector = null;\n /** @type {HTMLStyleElement} */\n this.customStyle = null;\n }\n _getStyleRules() {\n return this.styleRules;\n }\n}\n\nStyleInfo.prototype['_getStyleRules'] = StyleInfo.prototype._getStyleRules;","/**\n@license\nCopyright (c) 2017 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 {removeCustomPropAssignment, StyleNode} from './css-parse.js'; // eslint-disable-line no-unused-vars\nimport {nativeShadow} from './style-settings.js';\nimport StyleTransformer from './style-transformer.js';\nimport * as StyleUtil from './style-util.js';\nimport * as RX from './common-regex.js';\nimport StyleInfo from './style-info.js';\n\n// TODO: dedupe with shady\n/**\n * @const {function(string):boolean}\n */\nconst matchesSelector = ((p) => p.matches || p.matchesSelector ||\n p.mozMatchesSelector || p.msMatchesSelector ||\np.oMatchesSelector || p.webkitMatchesSelector)(window.Element.prototype);\n\nconst IS_IE = navigator.userAgent.match('Trident');\n\nconst XSCOPE_NAME = 'x-scope';\n\nclass StyleProperties {\n get XSCOPE_NAME() {\n return XSCOPE_NAME;\n }\n/**\n * decorates styles with rule info and returns an array of used style property names\n *\n * @param {StyleNode} rules\n * @return {Array}\n */\n decorateStyles(rules) {\n let self = this, props = {}, keyframes = [], ruleIndex = 0;\n StyleUtil.forEachRule(rules, function(rule) {\n self.decorateRule(rule);\n // mark in-order position of ast rule in styles block, used for cache key\n rule.index = ruleIndex++;\n self.collectPropertiesInCssText(rule.propertyInfo.cssText, props);\n }, function onKeyframesRule(rule) {\n keyframes.push(rule);\n });\n // Cache all found keyframes rules for later reference:\n rules._keyframes = keyframes;\n // return this list of property names *consumes* in these styles.\n let names = [];\n for (let i in props) {\n names.push(i);\n }\n return names;\n }\n\n // decorate a single rule with property info\n decorateRule(rule) {\n if (rule.propertyInfo) {\n return rule.propertyInfo;\n }\n let info = {}, properties = {};\n let hasProperties = this.collectProperties(rule, properties);\n if (hasProperties) {\n info.properties = properties;\n // TODO(sorvell): workaround parser seeing mixins as additional rules\n rule['rules'] = null;\n }\n info.cssText = this.collectCssText(rule);\n rule.propertyInfo = info;\n return info;\n }\n\n // collects the custom properties from a rule's cssText\n collectProperties(rule, properties) {\n let info = rule.propertyInfo;\n if (info) {\n if (info.properties) {\n Object.assign(properties, info.properties);\n return true;\n }\n } else {\n let m, rx = RX.VAR_ASSIGN;\n let cssText = rule['parsedCssText'];\n let value;\n let any;\n while ((m = rx.exec(cssText))) {\n // note: group 2 is var, 3 is mixin\n value = (m[2] || m[3]).trim();\n // value of 'inherit' or 'unset' is equivalent to not setting the property here\n if (value !== 'inherit' || value !== 'unset') {\n properties[m[1].trim()] = value;\n }\n any = true;\n }\n return any;\n }\n\n }\n\n // returns cssText of properties that consume variables/mixins\n collectCssText(rule) {\n return this.collectConsumingCssText(rule['parsedCssText']);\n }\n\n // NOTE: we support consumption inside mixin assignment\n // but not production, so strip out {...}\n collectConsumingCssText(cssText) {\n return cssText.replace(RX.BRACKETED, '')\n .replace(RX.VAR_ASSIGN, '');\n }\n\n collectPropertiesInCssText(cssText, props) {\n let m;\n while ((m = RX.VAR_CONSUMED.exec(cssText))) {\n let name = m[1];\n // This regex catches all variable names, and following non-whitespace char\n // If next char is not ':', then variable is a consumer\n if (m[2] !== ':') {\n props[name] = true;\n }\n }\n }\n\n // turns custom properties into realized values.\n reify(props) {\n // big perf optimization here: reify only *own* properties\n // since this object has __proto__ of the element's scope properties\n let names = Object.getOwnPropertyNames(props);\n for (let i=0, n; i < names.length; i++) {\n n = names[i];\n props[n] = this.valueForProperty(props[n], props);\n }\n }\n\n // given a property value, returns the reified value\n // a property value may be:\n // (1) a literal value like: red or 5px;\n // (2) a variable value like: var(--a), var(--a, red), or var(--a, --b) or\n // var(--a, var(--b));\n // (3) a literal mixin value like { properties }. Each of these properties\n // can have values that are: (a) literal, (b) variables, (c) @apply mixins.\n valueForProperty(property, props) {\n // case (1) default\n // case (3) defines a mixin and we have to reify the internals\n if (property) {\n if (property.indexOf(';') >=0) {\n property = this.valueForProperties(property, props);\n } else {\n // case (2) variable\n let self = this;\n let fn = function(prefix, value, fallback, suffix) {\n if (!value) {\n return prefix + suffix;\n }\n let propertyValue = self.valueForProperty(props[value], props);\n // if value is \"initial\", then the variable should be treated as unset\n if (!propertyValue || propertyValue === 'initial') {\n // fallback may be --a or var(--a) or literal\n propertyValue = self.valueForProperty(props[fallback] || fallback, props) ||\n fallback;\n } else if (propertyValue === 'apply-shim-inherit') {\n // CSS build will replace `inherit` with `apply-shim-inherit`\n // for use with native css variables.\n // Since we have full control, we can use `inherit` directly.\n propertyValue = 'inherit';\n }\n return prefix + (propertyValue || '') + suffix;\n };\n property = StyleUtil.processVariableAndFallback(property, fn);\n }\n }\n return property && property.trim() || '';\n }\n\n // note: we do not yet support mixin within mixin\n valueForProperties(property, props) {\n let parts = property.split(';');\n for (let i=0, p, m; i *' || parsedSelector === 'html');\n let isHost = parsedSelector.indexOf(':host') === 0 && !isRoot;\n // build info is either in scope (when scope is an element) or in the style\n // when scope is the default scope; note: this allows default scope to have\n // mixed mode built and unbuilt styles.\n if (cssBuild === 'shady') {\n // :root -> x-foo > *.x-foo for elements and html for custom-style\n isRoot = parsedSelector === (hostScope + ' > *.' + hostScope) || parsedSelector.indexOf('html') !== -1;\n // :host -> x-foo for elements, but sub-rules have .x-foo in them\n isHost = !isRoot && parsedSelector.indexOf(hostScope) === 0;\n }\n if (cssBuild === 'shadow') {\n isRoot = parsedSelector === ':host > *' || parsedSelector === 'html';\n isHost = isHost && !isRoot;\n }\n if (!isRoot && !isHost) {\n return;\n }\n let selectorToMatch = hostScope;\n if (isHost) {\n // need to transform :host under ShadowDOM because `:host` does not work with `matches`\n if (nativeShadow && !rule.transformedSelector) {\n // transform :host into a matchable selector\n rule.transformedSelector =\n StyleTransformer._transformRuleCss(\n rule,\n StyleTransformer._transformComplexSelector,\n StyleTransformer._calcElementScope(is),\n hostScope\n );\n }\n selectorToMatch = rule.transformedSelector || hostScope;\n }\n callback({\n selector: selectorToMatch,\n isHost: isHost,\n isRoot: isRoot\n });\n }\n/**\n * @param {Element} scope\n * @param {StyleNode} rules\n * @return {Object}\n */\n hostAndRootPropertiesForScope(scope, rules) {\n let hostProps = {}, rootProps = {}, self = this;\n // note: active rules excludes non-matching @media rules\n let cssBuild = rules && rules['__cssBuild'];\n StyleUtil.forEachRule(rules, function(rule) {\n // if scope is StyleDefaults, use _element for matchesSelector\n self.whenHostOrRootRule(scope, rule, cssBuild, function(info) {\n let element = scope._element || scope;\n if (matchesSelector.call(element, info.selector)) {\n if (info.isHost) {\n self.collectProperties(rule, hostProps);\n } else {\n self.collectProperties(rule, rootProps);\n }\n }\n });\n }, null, true);\n return {rootProps: rootProps, hostProps: hostProps};\n }\n\n /**\n * @param {Element} element\n * @param {Object} properties\n * @param {string} scopeSelector\n */\n transformStyles(element, properties, scopeSelector) {\n let self = this;\n let {is, typeExtension} = StyleUtil.getIsExtends(element);\n let hostSelector = StyleTransformer\n ._calcHostScope(is, typeExtension);\n let rxHostSelector = element.extends ?\n '\\\\' + hostSelector.slice(0, -1) + '\\\\]' :\n hostSelector;\n let hostRx = new RegExp(RX.HOST_PREFIX + rxHostSelector +\n RX.HOST_SUFFIX);\n let rules = StyleInfo.get(element).styleRules;\n let keyframeTransforms =\n this._elementKeyframeTransforms(element, rules, scopeSelector);\n return StyleTransformer.elementStyles(element, rules, function(rule) {\n self.applyProperties(rule, properties);\n if (!nativeShadow &&\n !StyleUtil.isKeyframesSelector(rule) &&\n rule['cssText']) {\n // NOTE: keyframe transforms only scope munge animation names, so it\n // is not necessary to apply them in ShadowDOM.\n self.applyKeyframeTransforms(rule, keyframeTransforms);\n self._scopeSelector(rule, hostRx, hostSelector, scopeSelector);\n }\n });\n }\n\n /**\n * @param {Element} element\n * @param {StyleNode} rules\n * @param {string} scopeSelector\n * @return {Object}\n */\n _elementKeyframeTransforms(element, rules, scopeSelector) {\n let keyframesRules = rules._keyframes;\n let keyframeTransforms = {};\n if (!nativeShadow && keyframesRules) {\n // For non-ShadowDOM, we transform all known keyframes rules in\n // advance for the current scope. This allows us to catch keyframes\n // rules that appear anywhere in the stylesheet:\n for (let i = 0, keyframesRule = keyframesRules[i];\n i < keyframesRules.length;\n keyframesRule = keyframesRules[++i]) {\n this._scopeKeyframes(keyframesRule, scopeSelector);\n keyframeTransforms[keyframesRule['keyframesName']] =\n this._keyframesRuleTransformer(keyframesRule);\n }\n }\n return keyframeTransforms;\n }\n\n // Generate a factory for transforming a chunk of CSS text to handle a\n // particular scoped keyframes rule.\n /**\n * @param {StyleNode} keyframesRule\n * @return {function(string):string}\n */\n _keyframesRuleTransformer(keyframesRule) {\n return function(cssText) {\n return cssText.replace(\n keyframesRule.keyframesNameRx,\n keyframesRule.transformedKeyframesName);\n };\n }\n\n/**\n * Transforms `@keyframes` names to be unique for the current host.\n * Example: @keyframes foo-anim -> @keyframes foo-anim-x-foo-0\n *\n * @param {StyleNode} rule\n * @param {string} scopeId\n */\n _scopeKeyframes(rule, scopeId) {\n rule.keyframesNameRx = new RegExp(rule['keyframesName'], 'g');\n rule.transformedKeyframesName = rule['keyframesName'] + '-' + scopeId;\n rule.transformedSelector = rule.transformedSelector || rule['selector'];\n rule['selector'] = rule.transformedSelector.replace(\n rule['keyframesName'], rule.transformedKeyframesName);\n }\n\n // Strategy: x scope shim a selector e.g. to scope `.x-foo-42` (via classes):\n // non-host selector: .a.x-foo -> .x-foo-42 .a.x-foo\n // host selector: x-foo.wide -> .x-foo-42.wide\n // note: we use only the scope class (.x-foo-42) and not the hostSelector\n // (x-foo) to scope :host rules; this helps make property host rules\n // have low specificity. They are overrideable by class selectors but,\n // unfortunately, not by type selectors (e.g. overriding via\n // `.special` is ok, but not by `x-foo`).\n /**\n * @param {StyleNode} rule\n * @param {RegExp} hostRx\n * @param {string} hostSelector\n * @param {string} scopeId\n */\n _scopeSelector(rule, hostRx, hostSelector, scopeId) {\n rule.transformedSelector = rule.transformedSelector || rule['selector'];\n let selector = rule.transformedSelector;\n let scope = '.' + scopeId;\n let parts = selector.split(',');\n for (let i=0, l=parts.length, p; (i -1) {\n // @media rules may be stale in IE 10 and 11\n // refresh the text content of the style to revalidate them.\n style.textContent = cssText;\n }\n StyleUtil.applyStyle(style, null, styleInfo.placeholder);\n }\n }\n // ensure this style is our custom style and increment its use count.\n if (style) {\n style['_useCount'] = style['_useCount'] || 0;\n // increment use count if we changed styles\n if (styleInfo.customStyle != style) {\n style['_useCount']++;\n }\n styleInfo.customStyle = style;\n }\n return style;\n }\n\n /**\n * @param {Element} style\n * @param {Object} properties\n */\n applyCustomStyle(style, properties) {\n let rules = StyleUtil.rulesForStyle(/** @type {HTMLStyleElement} */(style));\n let self = this;\n style.textContent = StyleUtil.toCssText(rules, function(/** StyleNode */rule) {\n let css = rule['cssText'] = rule['parsedCssText'];\n if (rule.propertyInfo && rule.propertyInfo.cssText) {\n // remove property assignments\n // so next function isn't confused\n // NOTE: we have 3 categories of css:\n // (1) normal properties,\n // (2) custom property assignments (--foo: red;),\n // (3) custom property usage: border: var(--foo); @apply(--foo);\n // In elements, 1 and 3 are separated for efficiency; here they\n // are not and this makes this case unique.\n css = removeCustomPropAssignment(/** @type {string} */(css));\n // replace with reified properties, scenario is same as mixin\n rule['cssText'] = self.valueForProperties(css, properties);\n }\n });\n }\n}\n\n/**\n * @param {number} n\n * @param {Array} bits\n */\nfunction addToBitMask(n, bits) {\n let o = parseInt(n / 32, 10);\n let v = 1 << (n % 32);\n bits[o] = (bits[o] || 0) | v;\n}\n\nexport default new StyleProperties();","/**\n@license\nCopyright (c) 2017 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 {applyStylePlaceHolder} from './style-util.js';\nimport {nativeShadow} from './style-settings.js';\n\n/** @type {Object} */\nlet placeholderMap = {};\n\n/**\n * @const {CustomElementRegistry}\n */\nconst ce = window['customElements'];\nif (ce && !nativeShadow) {\n /**\n * @const {function(this:CustomElementRegistry, string,function(new:HTMLElement),{extends: string}=)}\n */\n const origDefine = ce['define'];\n /**\n * @param {string} name\n * @param {function(new:HTMLElement)} clazz\n * @param {{extends: string}=} options\n * @return {function(new:HTMLElement)}\n */\n const wrappedDefine = (name, clazz, options) => {\n placeholderMap[name] = applyStylePlaceHolder(name);\n return origDefine.call(/** @type {!CustomElementRegistry} */(ce), name, clazz, options);\n }\n ce['define'] = wrappedDefine;\n}\n\nexport default placeholderMap;\n","/**\n@license\nCopyright (c) 2017 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 {parse, StyleNode} from './css-parse.js';\nimport {nativeShadow, nativeCssVariables} from './style-settings.js';\nimport StyleTransformer from './style-transformer.js';\nimport * as StyleUtil from './style-util.js';\nimport StyleProperties from './style-properties.js';\nimport placeholderMap from './style-placeholder.js';\nimport StyleInfo from './style-info.js';\nimport StyleCache from './style-cache.js';\nimport {flush as watcherFlush} from './document-watcher.js';\nimport templateMap from './template-map.js';\nimport * as ApplyShimUtils from './apply-shim-utils.js';\nimport documentWait from './document-wait.js';\nimport {updateNativeProperties, detectMixin} from './common-utils.js';\nimport {CustomStyleInterfaceInterface} from './custom-style-interface.js'; // eslint-disable-line no-unused-vars\n\n/**\n * @const {StyleCache}\n */\nconst styleCache = new StyleCache();\n\nexport default class ScopingShim {\n constructor() {\n this._scopeCounter = {};\n this._documentOwner = document.documentElement;\n let ast = new StyleNode();\n ast['rules'] = [];\n this._documentOwnerStyleInfo = StyleInfo.set(this._documentOwner, new StyleInfo(ast));\n this._elementsHaveApplied = false;\n this._applyShim = null;\n /** @type {?CustomStyleInterfaceInterface} */\n this._customStyleInterface = null;\n documentWait(() => {\n this._ensure();\n });\n }\n flush() {\n watcherFlush();\n }\n _generateScopeSelector(name) {\n let id = this._scopeCounter[name] = (this._scopeCounter[name] || 0) + 1;\n return `${name}-${id}`;\n }\n getStyleAst(style) {\n return StyleUtil.rulesForStyle(style);\n }\n styleAstToString(ast) {\n return StyleUtil.toCssText(ast);\n }\n _gatherStyles(template) {\n return StyleUtil.gatherStyleText(template.content);\n }\n _getCssBuild(template) {\n let style = template.content.querySelector('style');\n if (!style) {\n return '';\n }\n return style.getAttribute('css-build') || '';\n }\n /**\n * Prepare the styling and template for the given element type\n *\n * @param {HTMLTemplateElement} template\n * @param {string} elementName\n * @param {string=} typeExtension\n */\n prepareTemplate(template, elementName, typeExtension) {\n if (template._prepared) {\n return;\n }\n template._prepared = true;\n template.name = elementName;\n template.extends = typeExtension;\n templateMap[elementName] = template;\n let cssBuild = this._getCssBuild(template);\n let cssText = this._gatherStyles(template);\n let info = {\n is: elementName,\n extends: typeExtension,\n __cssBuild: cssBuild,\n };\n if (!nativeShadow) {\n StyleTransformer.dom(template.content, elementName);\n }\n // check if the styling has mixin definitions or uses\n this._ensure();\n let hasMixins = detectMixin(cssText)\n let ast = parse(cssText);\n // only run the applyshim transforms if there is a mixin involved\n if (hasMixins && nativeCssVariables && this._applyShim) {\n this._applyShim['transformRules'](ast, elementName);\n }\n template['_styleAst'] = ast;\n template._cssBuild = cssBuild;\n\n let ownPropertyNames = [];\n if (!nativeCssVariables) {\n ownPropertyNames = StyleProperties.decorateStyles(template['_styleAst'], info);\n }\n if (!ownPropertyNames.length || nativeCssVariables) {\n let root = nativeShadow ? template.content : null;\n let placeholder = placeholderMap[elementName];\n let style = this._generateStaticStyle(info, template['_styleAst'], root, placeholder);\n template._style = style;\n }\n template._ownPropertyNames = ownPropertyNames;\n }\n _generateStaticStyle(info, rules, shadowroot, placeholder) {\n let cssText = StyleTransformer.elementStyles(info, rules);\n if (cssText.length) {\n return StyleUtil.applyCss(cssText, info.is, shadowroot, placeholder);\n }\n }\n _prepareHost(host) {\n let {is, typeExtension} = StyleUtil.getIsExtends(host);\n let placeholder = placeholderMap[is];\n let template = templateMap[is];\n let ast;\n let ownStylePropertyNames;\n let cssBuild;\n if (template) {\n ast = template['_styleAst'];\n ownStylePropertyNames = template._ownPropertyNames;\n cssBuild = template._cssBuild;\n }\n return StyleInfo.set(host,\n new StyleInfo(\n ast,\n placeholder,\n ownStylePropertyNames,\n is,\n typeExtension,\n cssBuild\n )\n );\n }\n _ensureApplyShim() {\n if (this._applyShim) {\n return;\n } else if (window.ShadyCSS && window.ShadyCSS.ApplyShim) {\n this._applyShim = window.ShadyCSS.ApplyShim;\n this._applyShim['invalidCallback'] = ApplyShimUtils.invalidate;\n }\n }\n _ensureCustomStyleInterface() {\n if (this._customStyleInterface) {\n return;\n } else if (window.ShadyCSS && window.ShadyCSS.CustomStyleInterface) {\n this._customStyleInterface = /** @type {!CustomStyleInterfaceInterface} */(window.ShadyCSS.CustomStyleInterface);\n /** @type {function(!HTMLStyleElement)} */\n this._customStyleInterface['transformCallback'] = (style) => {this.transformCustomStyleForDocument(style)};\n this._customStyleInterface['validateCallback'] = () => {\n requestAnimationFrame(() => {\n if (this._customStyleInterface['enqueued'] || this._elementsHaveApplied) {\n this.flushCustomStyles();\n }\n })\n };\n }\n }\n _ensure() {\n this._ensureApplyShim();\n this._ensureCustomStyleInterface();\n }\n /**\n * Flush and apply custom styles to document\n */\n flushCustomStyles() {\n this._ensure();\n if (!this._customStyleInterface) {\n return;\n }\n let customStyles = this._customStyleInterface['processStyles']();\n // early return if custom-styles don't need validation\n if (!this._customStyleInterface['enqueued']) {\n return;\n }\n if (!nativeCssVariables) {\n this._updateProperties(this._documentOwner, this._documentOwnerStyleInfo);\n this._applyCustomStyles(customStyles);\n } else {\n this._revalidateCustomStyleApplyShim(customStyles);\n }\n this._customStyleInterface['enqueued'] = false;\n // if custom elements have upgraded and there are no native css variables, we must recalculate the whole tree\n if (this._elementsHaveApplied && !nativeCssVariables) {\n this.styleDocument();\n }\n }\n /**\n * Apply styles for the given element\n *\n * @param {!HTMLElement} host\n * @param {Object=} overrideProps\n */\n styleElement(host, overrideProps) {\n let {is} = StyleUtil.getIsExtends(host);\n let styleInfo = StyleInfo.get(host);\n if (!styleInfo) {\n styleInfo = this._prepareHost(host);\n }\n // Only trip the `elementsHaveApplied` flag if a node other that the root document has `applyStyle` called\n if (!this._isRootOwner(host)) {\n this._elementsHaveApplied = true;\n }\n if (overrideProps) {\n styleInfo.overrideStyleProperties =\n styleInfo.overrideStyleProperties || {};\n Object.assign(styleInfo.overrideStyleProperties, overrideProps);\n }\n if (!nativeCssVariables) {\n this._updateProperties(host, styleInfo);\n if (styleInfo.ownStylePropertyNames && styleInfo.ownStylePropertyNames.length) {\n this._applyStyleProperties(host, styleInfo);\n }\n } else {\n if (styleInfo.overrideStyleProperties) {\n updateNativeProperties(host, styleInfo.overrideStyleProperties);\n }\n let template = templateMap[is];\n // bail early if there is no shadowroot for this element\n if (!template && !this._isRootOwner(host)) {\n return;\n }\n if (template && template._style && !ApplyShimUtils.templateIsValid(template)) {\n // update template\n if (!ApplyShimUtils.templateIsValidating(template)) {\n this._ensure();\n this._applyShim && this._applyShim['transformRules'](template['_styleAst'], is);\n template._style.textContent = StyleTransformer.elementStyles(host, styleInfo.styleRules);\n ApplyShimUtils.startValidatingTemplate(template);\n }\n // update instance if native shadowdom\n if (nativeShadow) {\n let root = host.shadowRoot;\n if (root) {\n let style = root.querySelector('style');\n style.textContent = StyleTransformer.elementStyles(host, styleInfo.styleRules);\n }\n }\n styleInfo.styleRules = template['_styleAst'];\n }\n }\n }\n _styleOwnerForNode(node) {\n let root = node.getRootNode();\n let host = root.host;\n if (host) {\n if (StyleInfo.get(host)) {\n return host;\n } else {\n return this._styleOwnerForNode(host);\n }\n }\n return this._documentOwner;\n }\n _isRootOwner(node) {\n return (node === this._documentOwner);\n }\n _applyStyleProperties(host, styleInfo) {\n let is = StyleUtil.getIsExtends(host).is;\n let cacheEntry = styleCache.fetch(is, styleInfo.styleProperties, styleInfo.ownStylePropertyNames);\n let cachedScopeSelector = cacheEntry && cacheEntry.scopeSelector;\n let cachedStyle = cacheEntry ? cacheEntry.styleElement : null;\n let oldScopeSelector = styleInfo.scopeSelector;\n // only generate new scope if cached style is not found\n styleInfo.scopeSelector = cachedScopeSelector || this._generateScopeSelector(is);\n let style = StyleProperties.applyElementStyle(host, styleInfo.styleProperties, styleInfo.scopeSelector, cachedStyle);\n if (!nativeShadow) {\n StyleProperties.applyElementScopeSelector(host, styleInfo.scopeSelector, oldScopeSelector);\n }\n if (!cacheEntry) {\n styleCache.store(is, styleInfo.styleProperties, style, styleInfo.scopeSelector);\n }\n return style;\n }\n _updateProperties(host, styleInfo) {\n let owner = this._styleOwnerForNode(host);\n let ownerStyleInfo = StyleInfo.get(owner);\n let ownerProperties = ownerStyleInfo.styleProperties;\n let props = Object.create(ownerProperties || null);\n let hostAndRootProps = StyleProperties.hostAndRootPropertiesForScope(host, styleInfo.styleRules);\n let propertyData = StyleProperties.propertyDataFromStyles(ownerStyleInfo.styleRules, host);\n let propertiesMatchingHost = propertyData.properties\n Object.assign(\n props,\n hostAndRootProps.hostProps,\n propertiesMatchingHost,\n hostAndRootProps.rootProps\n );\n this._mixinOverrideStyles(props, styleInfo.overrideStyleProperties);\n StyleProperties.reify(props);\n styleInfo.styleProperties = props;\n }\n _mixinOverrideStyles(props, overrides) {\n for (let p in overrides) {\n let v = overrides[p];\n // skip override props if they are not truthy or 0\n // in order to fall back to inherited values\n if (v || v === 0) {\n props[p] = v;\n }\n }\n }\n /**\n * Update styles of the whole document\n *\n * @param {Object=} properties\n */\n styleDocument(properties) {\n this.styleSubtree(this._documentOwner, properties);\n }\n /**\n * Update styles of a subtree\n *\n * @param {!HTMLElement} host\n * @param {Object=} properties\n */\n styleSubtree(host, properties) {\n let root = host.shadowRoot;\n if (root || this._isRootOwner(host)) {\n this.styleElement(host, properties);\n }\n // process the shadowdom children of `host`\n let shadowChildren = root && (root.children || root.childNodes);\n if (shadowChildren) {\n for (let i = 0; i < shadowChildren.length; i++) {\n let c = /** @type {!HTMLElement} */(shadowChildren[i]);\n this.styleSubtree(c);\n }\n } else {\n // process the lightdom children of `host`\n let children = host.children || host.childNodes;\n if (children) {\n for (let i = 0; i < children.length; i++) {\n let c = /** @type {!HTMLElement} */(children[i]);\n this.styleSubtree(c);\n }\n }\n }\n }\n /* Custom Style operations */\n _revalidateCustomStyleApplyShim(customStyles) {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n let s = this._customStyleInterface['getStyleForCustomStyle'](c);\n if (s) {\n this._revalidateApplyShim(s);\n }\n }\n }\n _applyCustomStyles(customStyles) {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n let s = this._customStyleInterface['getStyleForCustomStyle'](c);\n if (s) {\n StyleProperties.applyCustomStyle(s, this._documentOwnerStyleInfo.styleProperties);\n }\n }\n }\n transformCustomStyleForDocument(style) {\n let ast = StyleUtil.rulesForStyle(style);\n StyleUtil.forEachRule(ast, (rule) => {\n if (nativeShadow) {\n StyleTransformer.normalizeRootSelector(rule);\n } else {\n StyleTransformer.documentRule(rule);\n }\n if (nativeCssVariables) {\n this._ensure();\n this._applyShim && this._applyShim['transformRule'](rule);\n }\n });\n if (nativeCssVariables) {\n style.textContent = StyleUtil.toCssText(ast);\n } else {\n this._documentOwnerStyleInfo.styleRules.rules.push(ast);\n }\n }\n _revalidateApplyShim(style) {\n if (nativeCssVariables && this._applyShim) {\n let ast = StyleUtil.rulesForStyle(style);\n this._ensure();\n this._applyShim['transformRules'](ast);\n style.textContent = StyleUtil.toCssText(ast);\n }\n }\n getComputedStyleValue(element, property) {\n let value;\n if (!nativeCssVariables) {\n // element is either a style host, or an ancestor of a style host\n let styleInfo = StyleInfo.get(element) || StyleInfo.get(this._styleOwnerForNode(element));\n value = styleInfo.styleProperties[property];\n }\n // fall back to the property value from the computed styling\n value = value || window.getComputedStyle(element).getPropertyValue(property);\n // trim whitespace that can come after the `:` in css\n // example: padding: 2px -> \" 2px\"\n return value ? value.trim() : '';\n }\n // given an element and a classString, replaces\n // the element's class with the provided classString and adds\n // any necessary ShadyCSS static and property based scoping selectors\n setElementClass(element, classString) {\n let root = element.getRootNode();\n let classes = classString ? classString.split(/\\s/) : [];\n let scopeName = root.host && root.host.localName;\n // If no scope, try to discover scope name from existing class.\n // This can occur if, for example, a template stamped element that\n // has been scoped is manipulated when not in a root.\n if (!scopeName) {\n var classAttr = element.getAttribute('class');\n if (classAttr) {\n let k$ = classAttr.split(/\\s/);\n for (let i=0; i < k$.length; i++) {\n if (k$[i] === StyleTransformer.SCOPE_NAME) {\n scopeName = k$[i+1];\n break;\n }\n }\n }\n }\n if (scopeName) {\n classes.push(StyleTransformer.SCOPE_NAME, scopeName);\n }\n if (!nativeCssVariables) {\n let styleInfo = StyleInfo.get(element);\n if (styleInfo && styleInfo.scopeSelector) {\n classes.push(StyleProperties.XSCOPE_NAME, styleInfo.scopeSelector);\n }\n }\n StyleUtil.setElementClassRaw(element, classes.join(' '));\n }\n _styleInfoForNode(node) {\n return StyleInfo.get(node);\n }\n}\n\n/* exports */\nScopingShim.prototype['flush'] = ScopingShim.prototype.flush;\nScopingShim.prototype['prepareTemplate'] = ScopingShim.prototype.prepareTemplate;\nScopingShim.prototype['styleElement'] = ScopingShim.prototype.styleElement;\nScopingShim.prototype['styleDocument'] = ScopingShim.prototype.styleDocument;\nScopingShim.prototype['styleSubtree'] = ScopingShim.prototype.styleSubtree;\nScopingShim.prototype['getComputedStyleValue'] = ScopingShim.prototype.getComputedStyleValue;\nScopingShim.prototype['setElementClass'] = ScopingShim.prototype.setElementClass;\nScopingShim.prototype['_styleInfoForNode'] = ScopingShim.prototype._styleInfoForNode;\nScopingShim.prototype['transformCustomStyleForDocument'] = ScopingShim.prototype.transformCustomStyleForDocument;\nScopingShim.prototype['getStyleAst'] = ScopingShim.prototype.getStyleAst;\nScopingShim.prototype['styleAstToString'] = ScopingShim.prototype.styleAstToString;\nScopingShim.prototype['flushCustomStyles'] = ScopingShim.prototype.flushCustomStyles;\nObject.defineProperties(ScopingShim.prototype, {\n 'nativeShadow': {\n get() {\n return nativeShadow;\n }\n },\n 'nativeCss': {\n get() {\n return nativeCssVariables;\n }\n }\n});","/**\n@license\nCopyright (c) 2017 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'use strict';\n\nexport default class StyleCache {\n constructor(typeMax = 100) {\n // map element name -> [{properties, styleElement, scopeSelector}]\n this.cache = {};\n this.typeMax = typeMax;\n }\n\n _validate(cacheEntry, properties, ownPropertyNames) {\n for (let idx = 0; idx < ownPropertyNames.length; idx++) {\n let pn = ownPropertyNames[idx];\n if (cacheEntry.properties[pn] !== properties[pn]) {\n return false;\n }\n }\n return true;\n }\n\n store(tagname, properties, styleElement, scopeSelector) {\n let list = this.cache[tagname] || [];\n list.push({properties, styleElement, scopeSelector});\n if (list.length > this.typeMax) {\n list.shift();\n }\n this.cache[tagname] = list;\n }\n\n fetch(tagname, properties, ownPropertyNames) {\n let list = this.cache[tagname];\n if (!list) {\n return;\n }\n // reverse list for most-recent lookups\n for (let idx = list.length - 1; idx >= 0; idx--) {\n let entry = list[idx];\n if (this._validate(entry, properties, ownPropertyNames)) {\n return entry;\n }\n }\n }\n}\n","/**\n@license\nCopyright (c) 2017 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 { MIXIN_MATCH, VAR_ASSIGN } from './common-regex.js';\n\n/**\n * @param {Element} element\n * @param {Object=} properties\n */\nexport function updateNativeProperties(element, properties) {\n // remove previous properties\n for (let p in properties) {\n // NOTE: for bc with shim, don't apply null values.\n if (p === null) {\n element.style.removeProperty(p);\n } else {\n element.style.setProperty(p, properties[p]);\n }\n }\n}\n\n/**\n * @param {Element} element\n * @param {string} property\n * @return {string}\n */\nexport function getComputedStyleValue(element, property) {\n /**\n * @const {string}\n */\n const value = window.getComputedStyle(element).getPropertyValue(property);\n if (!value) {\n return '';\n } else {\n return value.trim();\n }\n}\n\n/**\n * return true if `cssText` contains a mixin definition or consumption\n * @param {string} cssText\n * @return {boolean}\n */\nexport function detectMixin(cssText) {\n const has = MIXIN_MATCH.test(cssText) || VAR_ASSIGN.test(cssText);\n // reset state of the regexes\n MIXIN_MATCH.lastIndex = 0;\n VAR_ASSIGN.lastIndex = 0;\n return has;\n}\n","/**\n@license\nCopyright (c) 2017 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 ScopingShim from '../src/scoping-shim.js';\nimport {nativeCssVariables, nativeShadow} from '../src/style-settings.js';\n\n/** @const {ScopingShim} */\nconst scopingShim = new ScopingShim();\n\nlet ApplyShim, CustomStyleInterface;\n\nif (window['ShadyCSS']) {\n ApplyShim = window['ShadyCSS']['ApplyShim'];\n CustomStyleInterface = window['ShadyCSS']['CustomStyleInterface'];\n}\n\nwindow.ShadyCSS = {\n ScopingShim: scopingShim,\n /**\n * @param {!HTMLTemplateElement} template\n * @param {string} elementName\n * @param {string=} elementExtends\n */\n prepareTemplate(template, elementName, elementExtends) {\n scopingShim.flushCustomStyles();\n scopingShim.prepareTemplate(template, elementName, elementExtends)\n },\n\n /**\n * @param {!HTMLElement} element\n * @param {Object=} properties\n */\n styleSubtree(element, properties) {\n scopingShim.flushCustomStyles();\n scopingShim.styleSubtree(element, properties);\n },\n\n /**\n * @param {!HTMLElement} element\n */\n styleElement(element) {\n scopingShim.flushCustomStyles();\n scopingShim.styleElement(element);\n },\n\n /**\n * @param {Object=} properties\n */\n styleDocument(properties) {\n scopingShim.flushCustomStyles();\n scopingShim.styleDocument(properties);\n },\n\n /**\n * @param {Element} element\n * @param {string} property\n * @return {string}\n */\n getComputedStyleValue(element, property) {\n return scopingShim.getComputedStyleValue(element, property);\n },\n\n nativeCss: nativeCssVariables,\n\n nativeShadow: nativeShadow\n};\n\nif (ApplyShim) {\n window.ShadyCSS.ApplyShim = ApplyShim;\n}\n\nif (CustomStyleInterface) {\n window.ShadyCSS.CustomStyleInterface = CustomStyleInterface;\n}"]} \ No newline at end of file +{"version":3,"sources":["src/template-map.js"," [synthetic:util/global] ","src/css-parse.js","src/apply-shim-utils.js","src/style-settings.js","src/common-regex.js","src/unscoped-style-handler.js","src/style-util.js","src/document-wait.js","src/style-transformer.js","src/document-watcher.js","src/style-info.js","src/style-properties.js","src/style-placeholder.js","src/scoping-shim.js","src/style-cache.js","src/common-utils.js","entrypoints/scoping-shim.js"],"names":["$jscomp.global","templateMap","constructor","StyleNode","parse","text","replace","RX$$module$src$css_parse.comments","RX$$module$src$css_parse.port","parseCss","root","length","n","i","l","OPEN_BRACE","p","previous","push","CLOSE_BRACE","node","t","substring","trim","ss","_expandUnicodeEscapes","RX$$module$src$css_parse.multipleSpaces","lastIndexOf","s","indexOf","AT_START","MEDIA_START","types$$module$src$css_parse.MEDIA_RULE","match","RX$$module$src$css_parse.keyframesRule","types$$module$src$css_parse.KEYFRAMES_RULE","split","pop","VAR_START","types$$module$src$css_parse.MIXIN_RULE","types$$module$src$css_parse.STYLE_RULE","r$","r","code","repeat","stringify","preserveProperties","cssText","rules","RX$$module$src$css_parse.customProp","RX$$module$src$css_parse.mixinProp","RX$$module$src$css_parse.mixinApply","RX$$module$src$css_parse.varApply","STYLE_RULE","KEYFRAMES_RULE","MEDIA_RULE","MIXIN_RULE","comments","port","customProp","mixinProp","mixinApply","varApply","keyframesRule","multipleSpaces","promise","Promise","resolve","invalidate","elementName","template","templateIsValid","startValidatingTemplate","_validating","then","nativeShadow","window","nativeCssVariables","calcCssVariables","settings","navigator","userAgent","CSS","supports","ShadyCSS","undefined","nativeCss","module$src$style_settings.nativeCssVariables","VAR_ASSIGN","MIXIN_MATCH","VAR_CONSUMED","ANIMATION_MATCH","MEDIA_MATCH","BRACKETED","styleTextSet","Set","toCssText","callback","forEachRule","rulesForStyle","style","textContent","isKeyframesSelector","rule","styleRuleCallback","keyframesRuleCallback","onlyActiveRules","skipRules","type","matchMedia","matches","applyCss","moniker","target","contextNode","document","createElement","setAttribute","applyStyle","lastHeadApplyNode","head","insertBefore","nextSibling","firstChild","compareDocumentPosition","position","Node","DOCUMENT_POSITION_PRECEDING","processVariableAndFallback","str","start","level","inner","end","prefix","suffix","comma","value","fallback","setElementClassRaw","element","call","getIsExtends","localName","typeExtension","is","getAttribute","extends","readyPromise","whenReady","resolveFn","documentWait","requestAnimationFrame","readyState","addEventListener","StyleTransformer","dom","scope","shouldRemoveScope","$jscompDefaultExport","_transformDom","selector","nodeType","ELEMENT_NODE","c$","childNodes","content","_content","children","classList","remove","SCOPE_NAME","add","c","CLASS","newValue","elementStyles","styleRules","cssBuildType","css","ext","hostScope","_calcHostScope","CSS_CLASS_PREFIX","isScoped","transformedSelector","_transformRuleCss","self","_transformComplexSelector","transformer","p$","COMPLEX_SELECTOR_SEP","join","_twiddleNthPlus","NTH","m","inside","stop","isNth","test","SLOTTED_START","HOST","SIMPLE_SELECTOR_SEP","info","_transformCompoundSelector","combinator","slottedIndex","SLOTTED","_transformHostSelector","_transformSimpleSelector","slotted","SLOTTED_PAREN","paren","DIR_PAREN","before","dir","PSEUDO_PREFIX","HOST_PAREN","SIMPLE_SELECTOR_PREFIX","host","typeSelector","SELECTOR_NO_MATCH","normalizeRootSelector","ROOT","_transformDocumentSelector","SCOPE_DOC_SELECTOR","$jscomp.global.Object.defineProperties","RegExp","flush","handler","mxns","x","mxn","documentElement","addedNodes","getRootNode","classes","Array","from","hasAttribute","idx","ownerDocument","currentScope","DOCUMENT_FRAGMENT_NODE","newScope","unscoped","j","observer","MutationObserver","observe","childList","subtree","delayedStart","body","listener","removeEventListener","takeRecords","module$src$document_watcher.flush","StyleInfo","ast","placeholder","ownStylePropertyNames","overrideStyleProperties","customStyle","scopeSelector","styleProperties","get","set","styleInfo","_getStyleRules","prototype","Element","matchesSelector","mozMatchesSelector","msMatchesSelector","oMatchesSelector","webkitMatchesSelector","IS_IE","StyleProperties","decorateStyles","props","keyframes","ruleIndex","decorateRule","index","propertyInfo","exec","name","onKeyframesRule","_keyframes","names","properties","collectProperties","hasProperties","Object","assign","any","valueForProperty","property","valueForProperties","fn","propertyValue","parts","lastIndex","colon","pp","slice","propertyDataFromStyles","o","selectorToMatch","parseInt","key","whenHostOrRootRule","cssBuild","parsedSelector","isRoot","isHost","hostAndRootPropertiesForScope","hostProps","rootProps","_element","transformStyles","hostSelector","hostRx","HOST_PREFIX","rxHostSelector","HOST_SUFFIX","StyleInfo$$module$src$style_info.get","keyframeTransforms","_elementKeyframeTransforms","output","input","hasAnimations","keyframeNamesToTransform","keyframe","transform","keyframesRules","keyframesNameRx","transformedKeyframesName","scopeId","_keyframesRuleTransformer","applyCustomStyle","XSCOPE_NAME","placeholderMap","ce","origDefine","wrappedDefine","clazz","options","placeHolder","createComment","after","styleCache","cache","typeMax","ScopingShim","_scopeCounter","_documentOwner","_documentOwnerStyleInfo","StyleInfo$$module$src$style_info.set","_elementsHaveApplied","_customStyleInterface","_applyShim","_ensure","ScopingShim$$module$src$scoping_shim.prototype","?.prototype","ScopingShim$$module$src$scoping_shim_prototype$flush","getStyleAst","styleAstToString","prepareTemplate","_prepared","querySelector","styleTextParts","styles","querySelectorAll","scopingAttribute","has","newStyle","cloneNode","appendChild","parentNode","removeChild","__cssBuild","_cssBuild","ownPropertyNames","shadowroot","_style","_ownPropertyNames","_ensureCustomStyleInterface","CustomStyleInterface","transformCustomStyleForDocument","flushCustomStyles","_ensureApplyShim","ApplyShim","customStyles","_revalidateCustomStyleApplyShim","_updateProperties","_applyCustomStyles","styleDocument","styleElement","overrideProps","_isRootOwner","removeProperty","setProperty","shadowRoot","list","entry","pn","cachedStyle","cacheEntry","oldScopeSelector","cachedScopeSelector","id","v","shift","_styleOwnerForNode","owner","ownerStyleInfo","create","hostAndRootProps","propertiesMatchingHost","propertyData","overrides","getOwnPropertyNames","styleSubtree","shadowChildren","_transformRule","getComputedStyleValue","getComputedStyle","getPropertyValue","setElementClass","classString","scopeName","classAttr","k$","_styleInfoForNode","defineProperties","scopingShim","elementExtends"],"mappings":"A;;;;;;;;;aAUA,IAAA,CAAA,CCiCAA,GAb2B,WAAlB,EAAC,MAAO,OAAR,EAAiC,MAAjC,GAa0B,IAb1B,CAa0B,IAb1B,CAEe,WAAlB,EAAC,MAAO,OAAR,EAA2C,IAA3C,EAAiC,MAAjC,CAAmD,MAAnD,CAW6B,IDjCnC,CAKMC,EAAc,E,CEIlBC,QADIC,EACO,EAAG,CAIZ,IAAA,IAAA,CAFA,IAAA,MAEA,CAFgB,CAQhB,KAAA,MAAA,CAFA,IAAA,OAEA,CAJA,IAAA,SAIA,CAJmB,IAQnB,KAAA,QAAA,CAFA,IAAA,cAEA,CAFwB,EAIxB,KAAA,OAAA,CAAiB,CAAA,CAEjB,KAAA,KAAA,CAAe,CAMf,KAAA,eAAA,CAFA,IAAA,SAEA,CAJA,IAAA,cAIA,CAJwB,EApBZ;AAmCTC,QAASA,EAAK,CAACC,CAAD,CAAO,CAC1BA,CAAA,CAAaA,CAUNC,QAAA,CAAgBC,EAAhB,CAA6B,EAA7B,CAAAD,QAAA,CAAyCE,EAAzC,CAAkD,EAAlD,CATAC,KAAAA,EAAA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M8V,EAAc,IHgBLlF,CGhBf,CAEIsC,EAFJ,CAEeJ,EAEXzT,OAAA,SAAJ,GACE6T,EACA,CADY7T,MAAA,SAAA,UACZ,CAAAyT,EAAA,CAAuBzT,MAAA,SAAA,qBAFzB,CAKAA,OAAAQ,SAAA,CAAkB,CAChB+Q,YAAakF,CADG,CAOhB,gBAAApE,QAAe,CAAC3S,CAAD,CAAWD,CAAX,CAAwBiX,CAAxB,CAAwC,CACrDD,CAAA9C,EAAA,EACA8C,EAAApE,gBAAA,CAA4B3S,CAA5B,CAAsCD,CAAtC,CAAmDiX,CAAnD,CAFqD,CAPvC,CAgBhB,aAAAd,QAAY,CAAC5R,CAAD,CAAUuJ,CAAV,CAAsB,CAChCkJ,CAAA9C,EAAA,EACA8C,EAAAb,aAAA,CAAyB5R,CAAzB,CAAkCuJ,CAAlC,CAFgC,CAhBlB,CAwBhB,aAAA4G,QAAY,CAACnQ,CAAD,CAAU,CACpByS,CAAA9C,EAAA,EACA8C,EAAAtC,aAAA,CAAyBnQ,CAAzB,CAFoB,CAxBN,CAgChB,cAAAkQ,QAAa,CAAC3G,CAAD,CAAa,CACxBkJ,CAAA9C,EAAA,EACA8C,EAAAvC,cAAA,CAA0B3G,CAA1B,CAFwB,CAhCV,CA0ChB,sBAAAwI,QAAqB,CAAC/R,CAAD,CAAU8J,CAAV,CAAoB,CACvC,MAAO2I,EAAAV,sBAAA,CAAkC/R,CAAlC,CAA2C8J,CAA3C,CADgC,CA1CzB,CA8ChBpN,UAAWC,CA9CK,CAgDhBZ,ab7DSA,CaaO,CAmDd8T,GAAJ,GACE7T,MAAAQ,SAAAqT,UADF,CAC8BA,EAD9B,CAIIJ;EAAJ,GACEzT,MAAAQ,SAAAiT,qBADF,CACyCA,EADzC","file":"scoping-shim.min.js","sourcesContent":["/**\n@license\nCopyright (c) 2017 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/**\n * @const {!Object}\n */\nconst templateMap = {};\nexport default templateMap;\n",null,"/**\n@license\nCopyright (c) 2017 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/*\nExtremely simple css parser. Intended to be not more than what we need\nand definitely not necessarily correct =).\n*/\n\n'use strict';\n\n/** @unrestricted */\nclass StyleNode {\n constructor() {\n /** @type {number} */\n this['start'] = 0;\n /** @type {number} */\n this['end'] = 0;\n /** @type {StyleNode} */\n this['previous'] = null;\n /** @type {StyleNode} */\n this['parent'] = null;\n /** @type {Array} */\n this['rules'] = null;\n /** @type {string} */\n this['parsedCssText'] = '';\n /** @type {string} */\n this['cssText'] = '';\n /** @type {boolean} */\n this['atRule'] = false;\n /** @type {number} */\n this['type'] = 0;\n /** @type {string} */\n this['keyframesName'] = '';\n /** @type {string} */\n this['selector'] = '';\n /** @type {string} */\n this['parsedSelector'] = '';\n }\n}\n\nexport {StyleNode}\n\n// given a string of css, return a simple rule tree\n/**\n * @param {string} text\n * @return {StyleNode}\n */\nexport function parse(text) {\n text = clean(text);\n return parseCss(lex(text), text);\n}\n\n// remove stuff we don't care about that may hinder parsing\n/**\n * @param {string} cssText\n * @return {string}\n */\nfunction clean(cssText) {\n return cssText.replace(RX.comments, '').replace(RX.port, '');\n}\n\n// super simple {...} lexer that returns a node tree\n/**\n * @param {string} text\n * @return {StyleNode}\n */\nfunction lex(text) {\n let root = new StyleNode();\n root['start'] = 0;\n root['end'] = text.length\n let n = root;\n for (let i = 0, l = text.length; i < l; i++) {\n if (text[i] === OPEN_BRACE) {\n if (!n['rules']) {\n n['rules'] = [];\n }\n let p = n;\n let previous = p['rules'][p['rules'].length - 1] || null;\n n = new StyleNode();\n n['start'] = i + 1;\n n['parent'] = p;\n n['previous'] = previous;\n p['rules'].push(n);\n } else if (text[i] === CLOSE_BRACE) {\n n['end'] = i + 1;\n n = n['parent'] || root;\n }\n }\n return root;\n}\n\n// add selectors/cssText to node tree\n/**\n * @param {StyleNode} node\n * @param {string} text\n * @return {StyleNode}\n */\nfunction parseCss(node, text) {\n let t = text.substring(node['start'], node['end'] - 1);\n node['parsedCssText'] = node['cssText'] = t.trim();\n if (node['parent']) {\n let ss = node['previous'] ? node['previous']['end'] : node['parent']['start'];\n t = text.substring(ss, node['start'] - 1);\n t = _expandUnicodeEscapes(t);\n t = t.replace(RX.multipleSpaces, ' ');\n // TODO(sorvell): ad hoc; make selector include only after last ;\n // helps with mixin syntax\n t = t.substring(t.lastIndexOf(';') + 1);\n let s = node['parsedSelector'] = node['selector'] = t.trim();\n node['atRule'] = (s.indexOf(AT_START) === 0);\n // note, support a subset of rule types...\n if (node['atRule']) {\n if (s.indexOf(MEDIA_START) === 0) {\n node['type'] = types.MEDIA_RULE;\n } else if (s.match(RX.keyframesRule)) {\n node['type'] = types.KEYFRAMES_RULE;\n node['keyframesName'] =\n node['selector'].split(RX.multipleSpaces).pop();\n }\n } else {\n if (s.indexOf(VAR_START) === 0) {\n node['type'] = types.MIXIN_RULE;\n } else {\n node['type'] = types.STYLE_RULE;\n }\n }\n }\n let r$ = node['rules'];\n if (r$) {\n for (let i = 0, l = r$.length, r;\n (i < l) && (r = r$[i]); i++) {\n parseCss(r, text);\n }\n }\n return node;\n}\n\n/**\n * conversion of sort unicode escapes with spaces like `\\33 ` (and longer) into\n * expanded form that doesn't require trailing space `\\000033`\n * @param {string} s\n * @return {string}\n */\nfunction _expandUnicodeEscapes(s) {\n return s.replace(/\\\\([0-9a-f]{1,6})\\s/gi, function() {\n let code = arguments[1],\n repeat = 6 - code.length;\n while (repeat--) {\n code = '0' + code;\n }\n return '\\\\' + code;\n });\n}\n\n/**\n * stringify parsed css.\n * @param {StyleNode} node\n * @param {boolean=} preserveProperties\n * @param {string=} text\n * @return {string}\n */\nexport function stringify(node, preserveProperties, text = '') {\n // calc rule cssText\n let cssText = '';\n if (node['cssText'] || node['rules']) {\n let r$ = node['rules'];\n if (r$ && !_hasMixinRules(r$)) {\n for (let i = 0, l = r$.length, r;\n (i < l) && (r = r$[i]); i++) {\n cssText = stringify(r, preserveProperties, cssText);\n }\n } else {\n cssText = preserveProperties ? node['cssText'] :\n removeCustomProps(node['cssText']);\n cssText = cssText.trim();\n if (cssText) {\n cssText = ' ' + cssText + '\\n';\n }\n }\n }\n // emit rule if there is cssText\n if (cssText) {\n if (node['selector']) {\n text += node['selector'] + ' ' + OPEN_BRACE + '\\n';\n }\n text += cssText;\n if (node['selector']) {\n text += CLOSE_BRACE + '\\n\\n';\n }\n }\n return text;\n}\n\n/**\n * @param {Array} rules\n * @return {boolean}\n */\nfunction _hasMixinRules(rules) {\n let r = rules[0];\n return Boolean(r) && Boolean(r['selector']) && r['selector'].indexOf(VAR_START) === 0;\n}\n\n/**\n * @param {string} cssText\n * @return {string}\n */\nfunction removeCustomProps(cssText) {\n cssText = removeCustomPropAssignment(cssText);\n return removeCustomPropApply(cssText);\n}\n\n/**\n * @param {string} cssText\n * @return {string}\n */\nexport function removeCustomPropAssignment(cssText) {\n return cssText\n .replace(RX.customProp, '')\n .replace(RX.mixinProp, '');\n}\n\n/**\n * @param {string} cssText\n * @return {string}\n */\nfunction removeCustomPropApply(cssText) {\n return cssText\n .replace(RX.mixinApply, '')\n .replace(RX.varApply, '');\n}\n\n/** @enum {number} */\nexport const types = {\n STYLE_RULE: 1,\n KEYFRAMES_RULE: 7,\n MEDIA_RULE: 4,\n MIXIN_RULE: 1000\n}\n\nconst OPEN_BRACE = '{';\nconst CLOSE_BRACE = '}';\n\n// helper regexp's\nconst RX = {\n comments: /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//gim,\n port: /@import[^;]*;/gim,\n customProp: /(?:^[^;\\-\\s}]+)?--[^;{}]*?:[^{};]*?(?:[;\\n]|$)/gim,\n mixinProp: /(?:^[^;\\-\\s}]+)?--[^;{}]*?:[^{};]*?{[^}]*?}(?:[;\\n]|$)?/gim,\n mixinApply: /@apply\\s*\\(?[^);]*\\)?\\s*(?:[;\\n]|$)?/gim,\n varApply: /[^;:]*?:[^;]*?var\\([^;]*\\)(?:[;\\n]|$)?/gim,\n keyframesRule: /^@[^\\s]*keyframes/,\n multipleSpaces: /\\s+/g\n}\n\nconst VAR_START = '--';\nconst MEDIA_START = '@media';\nconst AT_START = '@';\n","/**\n@license\nCopyright (c) 2017 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';\nimport templateMap from './template-map.js';\nimport {StyleNode} from './css-parse.js'; // eslint-disable-line no-unused-vars\n\n/*\n * Utilities for handling invalidating apply-shim mixins for a given template.\n *\n * The invalidation strategy involves keeping track of the \"current\" version of a template's mixins, and updating that count when a mixin is invalidated.\n * The template\n */\n\n/** @const {string} */\nconst CURRENT_VERSION = '_applyShimCurrentVersion';\n\n/** @const {string} */\nconst NEXT_VERSION = '_applyShimNextVersion';\n\n/** @const {string} */\nconst VALIDATING_VERSION = '_applyShimValidatingVersion';\n\n/**\n * @const {Promise}\n */\nconst promise = Promise.resolve();\n\n/**\n * @param {string} elementName\n */\nexport function invalidate(elementName){\n let template = templateMap[elementName];\n if (template) {\n invalidateTemplate(template);\n }\n}\n\n/**\n * This function can be called multiple times to mark a template invalid\n * and signal that the style inside must be regenerated.\n *\n * Use `startValidatingTemplate` to begin an asynchronous validation cycle.\n * During that cycle, call `templateIsValidating` to see if the template must\n * be revalidated\n * @param {HTMLTemplateElement} template\n */\nexport function invalidateTemplate(template) {\n // default the current version to 0\n template[CURRENT_VERSION] = template[CURRENT_VERSION] || 0;\n // ensure the \"validating for\" flag exists\n template[VALIDATING_VERSION] = template[VALIDATING_VERSION] || 0;\n // increment the next version\n template[NEXT_VERSION] = (template[NEXT_VERSION] || 0) + 1;\n}\n\n/**\n * @param {string} elementName\n * @return {boolean}\n */\nexport function isValid(elementName) {\n let template = templateMap[elementName];\n if (template) {\n return templateIsValid(template);\n }\n return true;\n}\n\n/**\n * @param {HTMLTemplateElement} template\n * @return {boolean}\n */\nexport function templateIsValid(template) {\n return template[CURRENT_VERSION] === template[NEXT_VERSION];\n}\n\n/**\n * @param {string} elementName\n * @return {boolean}\n */\nexport function isValidating(elementName) {\n let template = templateMap[elementName];\n if (template) {\n return templateIsValidating(template);\n }\n return false;\n}\n\n/**\n * Returns true if the template is currently invalid and `startValidating` has been called since the last invalidation.\n * If false, the template must be validated.\n * @param {HTMLTemplateElement} template\n * @return {boolean}\n */\nexport function templateIsValidating(template) {\n return !templateIsValid(template) && template[VALIDATING_VERSION] === template[NEXT_VERSION];\n}\n\n/**\n * the template is marked as `validating` for one microtask so that all instances\n * found in the tree crawl of `applyStyle` will update themselves,\n * but the template will only be updated once.\n * @param {string} elementName\n*/\nexport function startValidating(elementName) {\n let template = templateMap[elementName];\n startValidatingTemplate(template);\n}\n\n/**\n * Begin an asynchronous invalidation cycle.\n * This should be called after every validation of a template\n *\n * After one microtask, the template will be marked as valid until the next call to `invalidateTemplate`\n * @param {HTMLTemplateElement} template\n */\nexport function startValidatingTemplate(template) {\n // remember that the current \"next version\" is the reason for this validation cycle\n template[VALIDATING_VERSION] = template[NEXT_VERSION];\n // however, there only needs to be one async task to clear the counters\n if (!template._validating) {\n template._validating = true;\n promise.then(function() {\n // sync the current version to let future invalidations cause a refresh cycle\n template[CURRENT_VERSION] = template[NEXT_VERSION];\n template._validating = false;\n });\n }\n}\n\n/**\n * @return {boolean}\n */\nexport function elementsAreInvalid() {\n for (let elementName in templateMap) {\n let template = templateMap[elementName];\n if (!templateIsValid(template)) {\n return true;\n }\n }\n return false;\n}","/**\n@license\nCopyright (c) 2017 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 nativeShadow = !(window['ShadyDOM'] && window['ShadyDOM']['inUse']);\nexport let nativeCssVariables;\n\n/**\n * @param {(ShadyCSSOptions | ShadyCSSInterface)=} settings\n */\nfunction calcCssVariables(settings) {\n if (settings && settings['shimcssproperties']) {\n nativeCssVariables = false;\n } else {\n // chrome 49 has semi-working css vars, check if box-shadow works\n // safari 9.1 has a recalc bug: https://bugs.webkit.org/show_bug.cgi?id=155782\n // However, shim css custom properties are only supported with ShadyDOM enabled,\n // so fall back on native if we do not detect ShadyDOM\n // Edge 15: custom properties used in ::before and ::after will also be used in the parent element\n // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/12414257/\n nativeCssVariables = nativeShadow || Boolean(!navigator.userAgent.match(/AppleWebKit\\/601|Edge\\/15/) &&\n window.CSS && CSS.supports && CSS.supports('box-shadow', '0 0 0 var(--foo)'));\n }\n}\n\nif (window.ShadyCSS && window.ShadyCSS.nativeCss !== undefined) {\n nativeCssVariables = window.ShadyCSS.nativeCss;\n} else if (window.ShadyCSS) {\n calcCssVariables(window.ShadyCSS);\n // reset window variable to let ShadyCSS API take its place\n window.ShadyCSS = undefined;\n} else {\n calcCssVariables(window['WebComponents'] && window['WebComponents']['flags']);\n}","/**\n@license\nCopyright (c) 2017 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\nexport const VAR_ASSIGN = /(?:^|[;\\s{]\\s*)(--[\\w-]*?)\\s*:\\s*(?:((?:'(?:\\\\'|.)*?'|\"(?:\\\\\"|.)*?\"|\\([^)]*?\\)|[^};{])+)|\\{([^}]*)\\}(?:(?=[;\\s}])|$))/gi;\nexport const MIXIN_MATCH = /(?:^|\\W+)@apply\\s*\\(?([^);\\n]*)\\)?/gi;\nexport const VAR_CONSUMED = /(--[\\w-]+)\\s*([:,;)]|$)/gi;\nexport const ANIMATION_MATCH = /(animation\\s*:)|(animation-name\\s*:)/;\nexport const MEDIA_MATCH = /@media\\s(.*)/;\nexport const IS_VAR = /^--/;\nexport const BRACKETED = /\\{[^}]*\\}/g;\nexport const HOST_PREFIX = '(?:^|[^.#[:])';\nexport const HOST_SUFFIX = '($|[.:[\\\\s>+~])';\n","/**\n@license\nCopyright (c) 2017 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/** @type {!Set} */\nconst styleTextSet = new Set();\n\nexport const scopingAttribute = 'shady-unscoped';\n\n/**\n * Add a specifically-marked style to the document directly, and only one copy of that style.\n *\n * @param {!HTMLStyleElement} style\n * @return {undefined}\n */\nexport function processUnscopedStyle(style) {\n const text = style.textContent;\n if (!styleTextSet.has(text)) {\n styleTextSet.add(text);\n const newStyle = style.cloneNode(true);\n document.head.appendChild(newStyle);\n }\n}\n\n/**\n * Check if a style is supposed to be unscoped\n * @param {!HTMLStyleElement} style\n * @return {boolean} true if the style has the unscoping attribute\n */\nexport function isUnscopedStyle(style) {\n return style.hasAttribute(scopingAttribute);\n}","/**\n@license\nCopyright (c) 2017 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 {nativeShadow, nativeCssVariables} from './style-settings.js';\nimport {parse, stringify, types, StyleNode} from './css-parse.js'; // eslint-disable-line no-unused-vars\nimport {MEDIA_MATCH} from './common-regex.js';\nimport {processUnscopedStyle, isUnscopedStyle} from './unscoped-style-handler.js';\n\n/**\n * @param {string|StyleNode} rules\n * @param {function(StyleNode)=} callback\n * @return {string}\n */\nexport function toCssText (rules, callback) {\n if (!rules) {\n return '';\n }\n if (typeof rules === 'string') {\n rules = parse(rules);\n }\n if (callback) {\n forEachRule(rules, callback);\n }\n return stringify(rules, nativeCssVariables);\n}\n\n/**\n * @param {HTMLStyleElement} style\n * @return {StyleNode}\n */\nexport function rulesForStyle(style) {\n if (!style['__cssRules'] && style.textContent) {\n style['__cssRules'] = parse(style.textContent);\n }\n return style['__cssRules'] || null;\n}\n\n// Tests if a rule is a keyframes selector, which looks almost exactly\n// like a normal selector but is not (it has nothing to do with scoping\n// for example).\n/**\n * @param {StyleNode} rule\n * @return {boolean}\n */\nexport function isKeyframesSelector(rule) {\n return Boolean(rule['parent']) &&\n rule['parent']['type'] === types.KEYFRAMES_RULE;\n}\n\n/**\n * @param {StyleNode} node\n * @param {Function=} styleRuleCallback\n * @param {Function=} keyframesRuleCallback\n * @param {boolean=} onlyActiveRules\n */\nexport function forEachRule(node, styleRuleCallback, keyframesRuleCallback, onlyActiveRules) {\n if (!node) {\n return;\n }\n let skipRules = false;\n let type = node['type'];\n if (onlyActiveRules) {\n if (type === types.MEDIA_RULE) {\n let matchMedia = node['selector'].match(MEDIA_MATCH);\n if (matchMedia) {\n // if rule is a non matching @media rule, skip subrules\n if (!window.matchMedia(matchMedia[1]).matches) {\n skipRules = true;\n }\n }\n }\n }\n if (type === types.STYLE_RULE) {\n styleRuleCallback(node);\n } else if (keyframesRuleCallback &&\n type === types.KEYFRAMES_RULE) {\n keyframesRuleCallback(node);\n } else if (type === types.MIXIN_RULE) {\n skipRules = true;\n }\n let r$ = node['rules'];\n if (r$ && !skipRules) {\n for (let i=0, l=r$.length, r; (i`\n */\n if (localName) {\n if (localName.indexOf('-') > -1) {\n is = localName;\n } else {\n typeExtension = localName;\n is = (element.getAttribute && element.getAttribute('is')) || '';\n }\n } else {\n is = /** @type {?} */(element).is;\n typeExtension = /** @type {?} */(element).extends;\n }\n return {is, typeExtension};\n}\n\n/**\n * @param {Element|DocumentFragment} element\n * @return {string}\n */\nexport function gatherStyleText(element) {\n /** @type {!Array} */\n const styleTextParts = [];\n const styles = /** @type {!NodeList} */(element.querySelectorAll('style'));\n for (let i = 0; i < styles.length; i++) {\n const style = styles[i];\n if (isUnscopedStyle(style)) {\n if (!nativeShadow) {\n processUnscopedStyle(style);\n style.parentNode.removeChild(style);\n }\n } else {\n styleTextParts.push(style.textContent);\n style.parentNode.removeChild(style);\n }\n }\n return styleTextParts.join('').trim();\n}","/**\n@license\nCopyright (c) 2017 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/** @type {Promise} */\nlet readyPromise = null;\n\n/** @type {?function(?function())} */\nlet whenReady = window['HTMLImports'] && window['HTMLImports']['whenReady'] || null;\n\n/** @type {function()} */\nlet resolveFn;\n\n/**\n * @param {?function()} callback\n */\nexport default function documentWait(callback) {\n requestAnimationFrame(function() {\n if (whenReady) {\n whenReady(callback)\n } else {\n if (!readyPromise) {\n readyPromise = new Promise((resolve) => {resolveFn = resolve});\n if (document.readyState === 'complete') {\n resolveFn();\n } else {\n document.addEventListener('readystatechange', () => {\n if (document.readyState === 'complete') {\n resolveFn();\n }\n });\n }\n }\n readyPromise.then(function(){ callback && callback(); });\n }\n });\n}\n","/**\n@license\nCopyright (c) 2017 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 {StyleNode} from './css-parse.js'; // eslint-disable-line no-unused-vars\nimport * as StyleUtil from './style-util.js';\nimport {nativeShadow} from './style-settings.js';\n\n/* Transforms ShadowDOM styling into ShadyDOM styling\n\n* scoping:\n\n * elements in scope get scoping selector class=\"x-foo-scope\"\n * selectors re-written as follows:\n\n div button -> div.x-foo-scope button.x-foo-scope\n\n* :host -> scopeName\n\n* :host(...) -> scopeName...\n\n* ::slotted(...) -> scopeName > ...\n\n* ...:dir(ltr|rtl) -> [dir=\"ltr|rtl\"] ..., ...[dir=\"ltr|rtl\"]\n\n* :host(:dir[rtl]) -> scopeName:dir(rtl) -> [dir=\"rtl\"] scopeName, scopeName[dir=\"rtl\"]\n\n*/\nconst SCOPE_NAME = 'style-scope';\n\nclass StyleTransformer {\n get SCOPE_NAME() {\n return SCOPE_NAME;\n }\n // Given a node and scope name, add a scoping class to each node\n // in the tree. This facilitates transforming css into scoped rules.\n dom(node, scope, shouldRemoveScope) {\n // one time optimization to skip scoping...\n if (node['__styleScoped']) {\n node['__styleScoped'] = null;\n } else {\n this._transformDom(node, scope || '', shouldRemoveScope);\n }\n }\n\n _transformDom(node, selector, shouldRemoveScope) {\n if (node.nodeType === Node.ELEMENT_NODE) {\n this.element(node, selector, shouldRemoveScope);\n }\n let c$ = (node.localName === 'template') ?\n (node.content || node._content).childNodes :\n node.children || node.childNodes;\n if (c$) {\n for (let i=0; i {\n if (inside.indexOf('+') > -1) {\n inside = inside.replace(/\\+/g, '___');\n } else if (inside.indexOf('___') > -1) {\n inside = inside.replace(/___/g, '+');\n }\n return `:${type}(${inside})`;\n });\n }\n\n/**\n * @param {string} selector\n * @param {string} scope\n * @param {string=} hostScope\n */\n _transformComplexSelector(selector, scope, hostScope) {\n let stop = false;\n selector = selector.trim();\n // Remove spaces inside of selectors like `:nth-of-type` because it confuses SIMPLE_SELECTOR_SEP\n let isNth = NTH.test(selector);\n if (isNth) {\n selector = selector.replace(NTH, (m, type, inner) => `:${type}(${inner.replace(/\\s/g, '')})`)\n selector = this._twiddleNthPlus(selector);\n }\n selector = selector.replace(SLOTTED_START, `${HOST} $1`);\n selector = selector.replace(SIMPLE_SELECTOR_SEP, (m, c, s) => {\n if (!stop) {\n let info = this._transformCompoundSelector(s, c, scope, hostScope);\n stop = stop || info.stop;\n c = info.combinator;\n s = info.value;\n }\n return c + s;\n });\n if (isNth) {\n selector = this._twiddleNthPlus(selector);\n }\n return selector;\n }\n\n _transformCompoundSelector(selector, combinator, scope, hostScope) {\n // replace :host with host scoping class\n let slottedIndex = selector.indexOf(SLOTTED);\n if (selector.indexOf(HOST) >= 0) {\n selector = this._transformHostSelector(selector, hostScope);\n // replace other selectors with scoping class\n } else if (slottedIndex !== 0) {\n selector = scope ? this._transformSimpleSelector(selector, scope) :\n selector;\n }\n // mark ::slotted() scope jump to replace with descendant selector + arg\n // also ignore left-side combinator\n let slotted = false;\n if (slottedIndex >= 0) {\n combinator = '';\n slotted = true;\n }\n // process scope jumping selectors up to the scope jump and then stop\n let stop;\n if (slotted) {\n stop = true;\n if (slotted) {\n // .zonk ::slotted(.foo) -> .zonk.scope > .foo\n selector = selector.replace(SLOTTED_PAREN, (m, paren) => ` > ${paren}`);\n }\n }\n selector = selector.replace(DIR_PAREN, (m, before, dir) =>\n `[dir=\"${dir}\"] ${before}, ${before}[dir=\"${dir}\"]`);\n return {value: selector, combinator, stop};\n }\n\n _transformSimpleSelector(selector, scope) {\n let p$ = selector.split(PSEUDO_PREFIX);\n p$[0] += scope;\n return p$.join(PSEUDO_PREFIX);\n }\n\n // :host(...) -> scopeName...\n _transformHostSelector(selector, hostScope) {\n let m = selector.match(HOST_PAREN);\n let paren = m && m[2].trim() || '';\n if (paren) {\n if (!paren[0].match(SIMPLE_SELECTOR_PREFIX)) {\n // paren starts with a type selector\n let typeSelector = paren.split(SIMPLE_SELECTOR_PREFIX)[0];\n // if the type selector is our hostScope then avoid pre-pending it\n if (typeSelector === hostScope) {\n return paren;\n // otherwise, this selector should not match in this scope so\n // output a bogus selector.\n } else {\n return SELECTOR_NO_MATCH;\n }\n } else {\n // make sure to do a replace here to catch selectors like:\n // `:host(.foo)::before`\n return selector.replace(HOST_PAREN, function(m, host, paren) {\n return hostScope + paren;\n });\n }\n // if no paren, do a straight :host replacement.\n // TODO(sorvell): this should not strictly be necessary but\n // it's needed to maintain support for `:host[foo]` type selectors\n // which have been improperly used under Shady DOM. This should be\n // deprecated.\n } else {\n return selector.replace(HOST, hostScope);\n }\n }\n\n /**\n * @param {StyleNode} rule\n */\n documentRule(rule) {\n // reset selector in case this is redone.\n rule['selector'] = rule['parsedSelector'];\n this.normalizeRootSelector(rule);\n this._transformRule(rule, this._transformDocumentSelector);\n }\n\n /**\n * @param {StyleNode} rule\n */\n normalizeRootSelector(rule) {\n if (rule['selector'] === ROOT) {\n rule['selector'] = 'html';\n }\n }\n\n/**\n * @param {string} selector\n */\n _transformDocumentSelector(selector) {\n return selector.match(SLOTTED) ?\n this._transformComplexSelector(selector, SCOPE_DOC_SELECTOR) :\n this._transformSimpleSelector(selector.trim(), SCOPE_DOC_SELECTOR);\n }\n}\n\nlet NTH = /:(nth[-\\w]+)\\(([^)]+)\\)/;\nlet SCOPE_DOC_SELECTOR = `:not(.${SCOPE_NAME})`;\nlet COMPLEX_SELECTOR_SEP = ',';\nlet SIMPLE_SELECTOR_SEP = /(^|[\\s>+~]+)((?:\\[.+?\\]|[^\\s>+~=[])+)/g;\nlet SIMPLE_SELECTOR_PREFIX = /[[.:#*]/;\nlet HOST = ':host';\nlet ROOT = ':root';\nlet SLOTTED = '::slotted';\nlet SLOTTED_START = new RegExp(`^(${SLOTTED})`);\n// NOTE: this supports 1 nested () pair for things like\n// :host(:not([selected]), more general support requires\n// parsing which seems like overkill\nlet HOST_PAREN = /(:host)(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))/;\n// similar to HOST_PAREN\nlet SLOTTED_PAREN = /(?:::slotted)(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))/;\nlet DIR_PAREN = /(.*):dir\\((?:(ltr|rtl))\\)/;\nlet CSS_CLASS_PREFIX = '.';\nlet PSEUDO_PREFIX = ':';\nlet CLASS = 'class';\nlet SELECTOR_NO_MATCH = 'should_not_match';\n\nexport default new StyleTransformer()","/**\n@license\nCopyright (c) 2017 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 {nativeShadow} from './style-settings.js';\nimport StyleTransformer from './style-transformer.js';\nimport {getIsExtends} from './style-util.js';\n\nexport let flush = function() {};\n\n/**\n * @param {HTMLElement} element\n * @return {!Array}\n */\nfunction getClasses(element) {\n let classes = [];\n if (element.classList) {\n classes = Array.from(element.classList);\n } else if (element instanceof window['SVGElement'] && element.hasAttribute('class')) {\n classes = element.getAttribute('class').split(/\\s+/);\n }\n return classes;\n}\n\n/**\n * @param {HTMLElement} element\n * @return {string}\n */\nfunction getCurrentScope(element) {\n let classes = getClasses(element);\n let idx = classes.indexOf(StyleTransformer.SCOPE_NAME);\n if (idx > -1) {\n return classes[idx + 1];\n }\n return '';\n}\n\n/**\n * @param {Array|null} mxns\n */\nfunction handler(mxns) {\n for (let x=0; x < mxns.length; x++) {\n let mxn = mxns[x];\n if (mxn.target === document.documentElement ||\n mxn.target === document.head) {\n continue;\n }\n for (let i=0; i < mxn.addedNodes.length; i++) {\n let n = mxn.addedNodes[i];\n if (n.nodeType !== Node.ELEMENT_NODE) {\n continue;\n }\n n = /** @type {HTMLElement} */(n); // eslint-disable-line no-self-assign\n let root = n.getRootNode();\n let currentScope = getCurrentScope(n);\n // node was scoped, but now is in document\n if (currentScope && root === n.ownerDocument) {\n StyleTransformer.dom(n, currentScope, true);\n } else if (root.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n let newScope;\n let host = /** @type {ShadowRoot} */(root).host;\n // element may no longer be in a shadowroot\n if (!host) {\n continue;\n }\n newScope = getIsExtends(host).is;\n if (currentScope === newScope) {\n // make sure all the subtree elements are scoped correctly\n let unscoped = window['ShadyDOM']['nativeMethods']['querySelectorAll'].call(\n n, `:not(.${StyleTransformer.SCOPE_NAME})`);\n for (let j = 0; j < unscoped.length; j++) {\n StyleTransformer.element(unscoped[j], currentScope);\n }\n continue;\n }\n if (currentScope) {\n StyleTransformer.dom(n, currentScope, true);\n }\n StyleTransformer.dom(n, newScope);\n }\n }\n }\n}\n\nif (!nativeShadow) {\n let observer = new MutationObserver(handler);\n let start = (node) => {\n observer.observe(node, {childList: true, subtree: true});\n }\n let nativeCustomElements = (window['customElements'] &&\n !window['customElements']['polyfillWrapFlushCallback']);\n // need to start immediately with native custom elements\n // TODO(dfreedm): with polyfilled HTMLImports and native custom elements\n // excessive mutations may be observed; this can be optimized via cooperation\n // with the HTMLImports polyfill.\n if (nativeCustomElements) {\n start(document);\n } else {\n let delayedStart = () => {\n start(document.body);\n }\n // use polyfill timing if it's available\n if (window['HTMLImports']) {\n window['HTMLImports']['whenReady'](delayedStart);\n // otherwise push beyond native imports being ready\n // which requires RAF + readystate interactive.\n } else {\n requestAnimationFrame(function() {\n if (document.readyState === 'loading') {\n let listener = function() {\n delayedStart();\n document.removeEventListener('readystatechange', listener);\n }\n document.addEventListener('readystatechange', listener);\n } else {\n delayedStart();\n }\n });\n }\n }\n\n flush = function() {\n handler(observer.takeRecords());\n }\n}\n","/**\n@license\nCopyright (c) 2017 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 {StyleNode} from './css-parse.js'; // eslint-disable-line no-unused-vars\n\n/** @const {string} */\nconst infoKey = '__styleInfo';\n\nexport default class StyleInfo {\n /**\n * @param {Element} node\n * @return {StyleInfo}\n */\n static get(node) {\n if (node) {\n return node[infoKey];\n } else {\n return null;\n }\n }\n /**\n * @param {!Element} node\n * @param {StyleInfo} styleInfo\n * @return {StyleInfo}\n */\n static set(node, styleInfo) {\n node[infoKey] = styleInfo;\n return styleInfo;\n }\n /**\n * @param {StyleNode} ast\n * @param {Node=} placeholder\n * @param {Array=} ownStylePropertyNames\n * @param {string=} elementName\n * @param {string=} typeExtension\n * @param {string=} cssBuild\n */\n constructor(ast, placeholder, ownStylePropertyNames, elementName, typeExtension, cssBuild) {\n /** @type {StyleNode} */\n this.styleRules = ast || null;\n /** @type {Node} */\n this.placeholder = placeholder || null;\n /** @type {!Array} */\n this.ownStylePropertyNames = ownStylePropertyNames || [];\n /** @type {Array} */\n this.overrideStyleProperties = null;\n /** @type {string} */\n this.elementName = elementName || '';\n /** @type {string} */\n this.cssBuild = cssBuild || '';\n /** @type {string} */\n this.typeExtension = typeExtension || '';\n /** @type {Object} */\n this.styleProperties = null;\n /** @type {?string} */\n this.scopeSelector = null;\n /** @type {HTMLStyleElement} */\n this.customStyle = null;\n }\n _getStyleRules() {\n return this.styleRules;\n }\n}\n\nStyleInfo.prototype['_getStyleRules'] = StyleInfo.prototype._getStyleRules;","/**\n@license\nCopyright (c) 2017 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 {removeCustomPropAssignment, StyleNode} from './css-parse.js'; // eslint-disable-line no-unused-vars\nimport {nativeShadow} from './style-settings.js';\nimport StyleTransformer from './style-transformer.js';\nimport * as StyleUtil from './style-util.js';\nimport * as RX from './common-regex.js';\nimport StyleInfo from './style-info.js';\n\n// TODO: dedupe with shady\n/**\n * @const {function(string):boolean}\n */\nconst matchesSelector = ((p) => p.matches || p.matchesSelector ||\n p.mozMatchesSelector || p.msMatchesSelector ||\np.oMatchesSelector || p.webkitMatchesSelector)(window.Element.prototype);\n\nconst IS_IE = navigator.userAgent.match('Trident');\n\nconst XSCOPE_NAME = 'x-scope';\n\nclass StyleProperties {\n get XSCOPE_NAME() {\n return XSCOPE_NAME;\n }\n/**\n * decorates styles with rule info and returns an array of used style property names\n *\n * @param {StyleNode} rules\n * @return {Array}\n */\n decorateStyles(rules) {\n let self = this, props = {}, keyframes = [], ruleIndex = 0;\n StyleUtil.forEachRule(rules, function(rule) {\n self.decorateRule(rule);\n // mark in-order position of ast rule in styles block, used for cache key\n rule.index = ruleIndex++;\n self.collectPropertiesInCssText(rule.propertyInfo.cssText, props);\n }, function onKeyframesRule(rule) {\n keyframes.push(rule);\n });\n // Cache all found keyframes rules for later reference:\n rules._keyframes = keyframes;\n // return this list of property names *consumes* in these styles.\n let names = [];\n for (let i in props) {\n names.push(i);\n }\n return names;\n }\n\n // decorate a single rule with property info\n decorateRule(rule) {\n if (rule.propertyInfo) {\n return rule.propertyInfo;\n }\n let info = {}, properties = {};\n let hasProperties = this.collectProperties(rule, properties);\n if (hasProperties) {\n info.properties = properties;\n // TODO(sorvell): workaround parser seeing mixins as additional rules\n rule['rules'] = null;\n }\n info.cssText = this.collectCssText(rule);\n rule.propertyInfo = info;\n return info;\n }\n\n // collects the custom properties from a rule's cssText\n collectProperties(rule, properties) {\n let info = rule.propertyInfo;\n if (info) {\n if (info.properties) {\n Object.assign(properties, info.properties);\n return true;\n }\n } else {\n let m, rx = RX.VAR_ASSIGN;\n let cssText = rule['parsedCssText'];\n let value;\n let any;\n while ((m = rx.exec(cssText))) {\n // note: group 2 is var, 3 is mixin\n value = (m[2] || m[3]).trim();\n // value of 'inherit' or 'unset' is equivalent to not setting the property here\n if (value !== 'inherit' || value !== 'unset') {\n properties[m[1].trim()] = value;\n }\n any = true;\n }\n return any;\n }\n\n }\n\n // returns cssText of properties that consume variables/mixins\n collectCssText(rule) {\n return this.collectConsumingCssText(rule['parsedCssText']);\n }\n\n // NOTE: we support consumption inside mixin assignment\n // but not production, so strip out {...}\n collectConsumingCssText(cssText) {\n return cssText.replace(RX.BRACKETED, '')\n .replace(RX.VAR_ASSIGN, '');\n }\n\n collectPropertiesInCssText(cssText, props) {\n let m;\n while ((m = RX.VAR_CONSUMED.exec(cssText))) {\n let name = m[1];\n // This regex catches all variable names, and following non-whitespace char\n // If next char is not ':', then variable is a consumer\n if (m[2] !== ':') {\n props[name] = true;\n }\n }\n }\n\n // turns custom properties into realized values.\n reify(props) {\n // big perf optimization here: reify only *own* properties\n // since this object has __proto__ of the element's scope properties\n let names = Object.getOwnPropertyNames(props);\n for (let i=0, n; i < names.length; i++) {\n n = names[i];\n props[n] = this.valueForProperty(props[n], props);\n }\n }\n\n // given a property value, returns the reified value\n // a property value may be:\n // (1) a literal value like: red or 5px;\n // (2) a variable value like: var(--a), var(--a, red), or var(--a, --b) or\n // var(--a, var(--b));\n // (3) a literal mixin value like { properties }. Each of these properties\n // can have values that are: (a) literal, (b) variables, (c) @apply mixins.\n valueForProperty(property, props) {\n // case (1) default\n // case (3) defines a mixin and we have to reify the internals\n if (property) {\n if (property.indexOf(';') >=0) {\n property = this.valueForProperties(property, props);\n } else {\n // case (2) variable\n let self = this;\n let fn = function(prefix, value, fallback, suffix) {\n if (!value) {\n return prefix + suffix;\n }\n let propertyValue = self.valueForProperty(props[value], props);\n // if value is \"initial\", then the variable should be treated as unset\n if (!propertyValue || propertyValue === 'initial') {\n // fallback may be --a or var(--a) or literal\n propertyValue = self.valueForProperty(props[fallback] || fallback, props) ||\n fallback;\n } else if (propertyValue === 'apply-shim-inherit') {\n // CSS build will replace `inherit` with `apply-shim-inherit`\n // for use with native css variables.\n // Since we have full control, we can use `inherit` directly.\n propertyValue = 'inherit';\n }\n return prefix + (propertyValue || '') + suffix;\n };\n property = StyleUtil.processVariableAndFallback(property, fn);\n }\n }\n return property && property.trim() || '';\n }\n\n // note: we do not yet support mixin within mixin\n valueForProperties(property, props) {\n let parts = property.split(';');\n for (let i=0, p, m; i *' || parsedSelector === 'html');\n let isHost = parsedSelector.indexOf(':host') === 0 && !isRoot;\n // build info is either in scope (when scope is an element) or in the style\n // when scope is the default scope; note: this allows default scope to have\n // mixed mode built and unbuilt styles.\n if (cssBuild === 'shady') {\n // :root -> x-foo > *.x-foo for elements and html for custom-style\n isRoot = parsedSelector === (hostScope + ' > *.' + hostScope) || parsedSelector.indexOf('html') !== -1;\n // :host -> x-foo for elements, but sub-rules have .x-foo in them\n isHost = !isRoot && parsedSelector.indexOf(hostScope) === 0;\n }\n if (cssBuild === 'shadow') {\n isRoot = parsedSelector === ':host > *' || parsedSelector === 'html';\n isHost = isHost && !isRoot;\n }\n if (!isRoot && !isHost) {\n return;\n }\n let selectorToMatch = hostScope;\n if (isHost) {\n // need to transform :host under ShadowDOM because `:host` does not work with `matches`\n if (nativeShadow && !rule.transformedSelector) {\n // transform :host into a matchable selector\n rule.transformedSelector =\n StyleTransformer._transformRuleCss(\n rule,\n StyleTransformer._transformComplexSelector,\n StyleTransformer._calcElementScope(is),\n hostScope\n );\n }\n selectorToMatch = rule.transformedSelector || hostScope;\n }\n callback({\n selector: selectorToMatch,\n isHost: isHost,\n isRoot: isRoot\n });\n }\n/**\n * @param {Element} scope\n * @param {StyleNode} rules\n * @return {Object}\n */\n hostAndRootPropertiesForScope(scope, rules) {\n let hostProps = {}, rootProps = {}, self = this;\n // note: active rules excludes non-matching @media rules\n let cssBuild = rules && rules['__cssBuild'];\n StyleUtil.forEachRule(rules, function(rule) {\n // if scope is StyleDefaults, use _element for matchesSelector\n self.whenHostOrRootRule(scope, rule, cssBuild, function(info) {\n let element = scope._element || scope;\n if (matchesSelector.call(element, info.selector)) {\n if (info.isHost) {\n self.collectProperties(rule, hostProps);\n } else {\n self.collectProperties(rule, rootProps);\n }\n }\n });\n }, null, true);\n return {rootProps: rootProps, hostProps: hostProps};\n }\n\n /**\n * @param {Element} element\n * @param {Object} properties\n * @param {string} scopeSelector\n */\n transformStyles(element, properties, scopeSelector) {\n let self = this;\n let {is, typeExtension} = StyleUtil.getIsExtends(element);\n let hostSelector = StyleTransformer\n ._calcHostScope(is, typeExtension);\n let rxHostSelector = element.extends ?\n '\\\\' + hostSelector.slice(0, -1) + '\\\\]' :\n hostSelector;\n let hostRx = new RegExp(RX.HOST_PREFIX + rxHostSelector +\n RX.HOST_SUFFIX);\n let rules = StyleInfo.get(element).styleRules;\n let keyframeTransforms =\n this._elementKeyframeTransforms(element, rules, scopeSelector);\n return StyleTransformer.elementStyles(element, rules, function(rule) {\n self.applyProperties(rule, properties);\n if (!nativeShadow &&\n !StyleUtil.isKeyframesSelector(rule) &&\n rule['cssText']) {\n // NOTE: keyframe transforms only scope munge animation names, so it\n // is not necessary to apply them in ShadowDOM.\n self.applyKeyframeTransforms(rule, keyframeTransforms);\n self._scopeSelector(rule, hostRx, hostSelector, scopeSelector);\n }\n });\n }\n\n /**\n * @param {Element} element\n * @param {StyleNode} rules\n * @param {string} scopeSelector\n * @return {Object}\n */\n _elementKeyframeTransforms(element, rules, scopeSelector) {\n let keyframesRules = rules._keyframes;\n let keyframeTransforms = {};\n if (!nativeShadow && keyframesRules) {\n // For non-ShadowDOM, we transform all known keyframes rules in\n // advance for the current scope. This allows us to catch keyframes\n // rules that appear anywhere in the stylesheet:\n for (let i = 0, keyframesRule = keyframesRules[i];\n i < keyframesRules.length;\n keyframesRule = keyframesRules[++i]) {\n this._scopeKeyframes(keyframesRule, scopeSelector);\n keyframeTransforms[keyframesRule['keyframesName']] =\n this._keyframesRuleTransformer(keyframesRule);\n }\n }\n return keyframeTransforms;\n }\n\n // Generate a factory for transforming a chunk of CSS text to handle a\n // particular scoped keyframes rule.\n /**\n * @param {StyleNode} keyframesRule\n * @return {function(string):string}\n */\n _keyframesRuleTransformer(keyframesRule) {\n return function(cssText) {\n return cssText.replace(\n keyframesRule.keyframesNameRx,\n keyframesRule.transformedKeyframesName);\n };\n }\n\n/**\n * Transforms `@keyframes` names to be unique for the current host.\n * Example: @keyframes foo-anim -> @keyframes foo-anim-x-foo-0\n *\n * @param {StyleNode} rule\n * @param {string} scopeId\n */\n _scopeKeyframes(rule, scopeId) {\n // Animation names are of the form [\\w-], so ensure that the name regex does not partially apply\n // to similarly named keyframe names by checking for a word boundary at the beginning and\n // a non-word boundary or `-` at the end.\n rule.keyframesNameRx = new RegExp(`\\\\b${rule['keyframesName']}(?!\\\\B|-)`, 'g');\n rule.transformedKeyframesName = rule['keyframesName'] + '-' + scopeId;\n rule.transformedSelector = rule.transformedSelector || rule['selector'];\n rule['selector'] = rule.transformedSelector.replace(\n rule['keyframesName'], rule.transformedKeyframesName);\n }\n\n // Strategy: x scope shim a selector e.g. to scope `.x-foo-42` (via classes):\n // non-host selector: .a.x-foo -> .x-foo-42 .a.x-foo\n // host selector: x-foo.wide -> .x-foo-42.wide\n // note: we use only the scope class (.x-foo-42) and not the hostSelector\n // (x-foo) to scope :host rules; this helps make property host rules\n // have low specificity. They are overrideable by class selectors but,\n // unfortunately, not by type selectors (e.g. overriding via\n // `.special` is ok, but not by `x-foo`).\n /**\n * @param {StyleNode} rule\n * @param {RegExp} hostRx\n * @param {string} hostSelector\n * @param {string} scopeId\n */\n _scopeSelector(rule, hostRx, hostSelector, scopeId) {\n rule.transformedSelector = rule.transformedSelector || rule['selector'];\n let selector = rule.transformedSelector;\n let scope = '.' + scopeId;\n let parts = selector.split(',');\n for (let i=0, l=parts.length, p; (i -1) {\n // @media rules may be stale in IE 10 and 11\n // refresh the text content of the style to revalidate them.\n style.textContent = cssText;\n }\n StyleUtil.applyStyle(style, null, styleInfo.placeholder);\n }\n }\n // ensure this style is our custom style and increment its use count.\n if (style) {\n style['_useCount'] = style['_useCount'] || 0;\n // increment use count if we changed styles\n if (styleInfo.customStyle != style) {\n style['_useCount']++;\n }\n styleInfo.customStyle = style;\n }\n return style;\n }\n\n /**\n * @param {Element} style\n * @param {Object} properties\n */\n applyCustomStyle(style, properties) {\n let rules = StyleUtil.rulesForStyle(/** @type {HTMLStyleElement} */(style));\n let self = this;\n style.textContent = StyleUtil.toCssText(rules, function(/** StyleNode */rule) {\n let css = rule['cssText'] = rule['parsedCssText'];\n if (rule.propertyInfo && rule.propertyInfo.cssText) {\n // remove property assignments\n // so next function isn't confused\n // NOTE: we have 3 categories of css:\n // (1) normal properties,\n // (2) custom property assignments (--foo: red;),\n // (3) custom property usage: border: var(--foo); @apply(--foo);\n // In elements, 1 and 3 are separated for efficiency; here they\n // are not and this makes this case unique.\n css = removeCustomPropAssignment(/** @type {string} */(css));\n // replace with reified properties, scenario is same as mixin\n rule['cssText'] = self.valueForProperties(css, properties);\n }\n });\n }\n}\n\n/**\n * @param {number} n\n * @param {Array} bits\n */\nfunction addToBitMask(n, bits) {\n let o = parseInt(n / 32, 10);\n let v = 1 << (n % 32);\n bits[o] = (bits[o] || 0) | v;\n}\n\nexport default new StyleProperties();","/**\n@license\nCopyright (c) 2017 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 {applyStylePlaceHolder} from './style-util.js';\nimport {nativeShadow} from './style-settings.js';\n\n/** @type {Object} */\nlet placeholderMap = {};\n\n/**\n * @const {CustomElementRegistry}\n */\nconst ce = window['customElements'];\nif (ce && !nativeShadow) {\n /**\n * @const {function(this:CustomElementRegistry, string,function(new:HTMLElement),{extends: string}=)}\n */\n const origDefine = ce['define'];\n /**\n * @param {string} name\n * @param {function(new:HTMLElement)} clazz\n * @param {{extends: string}=} options\n * @return {function(new:HTMLElement)}\n */\n const wrappedDefine = (name, clazz, options) => {\n placeholderMap[name] = applyStylePlaceHolder(name);\n return origDefine.call(/** @type {!CustomElementRegistry} */(ce), name, clazz, options);\n }\n ce['define'] = wrappedDefine;\n}\n\nexport default placeholderMap;\n","/**\n@license\nCopyright (c) 2017 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 {parse, StyleNode} from './css-parse.js';\nimport {nativeShadow, nativeCssVariables} from './style-settings.js';\nimport StyleTransformer from './style-transformer.js';\nimport * as StyleUtil from './style-util.js';\nimport StyleProperties from './style-properties.js';\nimport placeholderMap from './style-placeholder.js';\nimport StyleInfo from './style-info.js';\nimport StyleCache from './style-cache.js';\nimport {flush as watcherFlush} from './document-watcher.js';\nimport templateMap from './template-map.js';\nimport * as ApplyShimUtils from './apply-shim-utils.js';\nimport documentWait from './document-wait.js';\nimport {updateNativeProperties, detectMixin} from './common-utils.js';\nimport {CustomStyleInterfaceInterface} from './custom-style-interface.js'; // eslint-disable-line no-unused-vars\n\n/**\n * @const {StyleCache}\n */\nconst styleCache = new StyleCache();\n\nexport default class ScopingShim {\n constructor() {\n this._scopeCounter = {};\n this._documentOwner = document.documentElement;\n let ast = new StyleNode();\n ast['rules'] = [];\n this._documentOwnerStyleInfo = StyleInfo.set(this._documentOwner, new StyleInfo(ast));\n this._elementsHaveApplied = false;\n this._applyShim = null;\n /** @type {?CustomStyleInterfaceInterface} */\n this._customStyleInterface = null;\n documentWait(() => {\n this._ensure();\n });\n }\n flush() {\n watcherFlush();\n }\n _generateScopeSelector(name) {\n let id = this._scopeCounter[name] = (this._scopeCounter[name] || 0) + 1;\n return `${name}-${id}`;\n }\n getStyleAst(style) {\n return StyleUtil.rulesForStyle(style);\n }\n styleAstToString(ast) {\n return StyleUtil.toCssText(ast);\n }\n _gatherStyles(template) {\n return StyleUtil.gatherStyleText(template.content);\n }\n _getCssBuild(template) {\n let style = template.content.querySelector('style');\n if (!style) {\n return '';\n }\n return style.getAttribute('css-build') || '';\n }\n /**\n * Prepare the styling and template for the given element type\n *\n * @param {HTMLTemplateElement} template\n * @param {string} elementName\n * @param {string=} typeExtension\n */\n prepareTemplate(template, elementName, typeExtension) {\n if (template._prepared) {\n return;\n }\n template._prepared = true;\n template.name = elementName;\n template.extends = typeExtension;\n templateMap[elementName] = template;\n let cssBuild = this._getCssBuild(template);\n let cssText = this._gatherStyles(template);\n let info = {\n is: elementName,\n extends: typeExtension,\n __cssBuild: cssBuild,\n };\n if (!nativeShadow) {\n StyleTransformer.dom(template.content, elementName);\n }\n // check if the styling has mixin definitions or uses\n this._ensure();\n let hasMixins = detectMixin(cssText)\n let ast = parse(cssText);\n // only run the applyshim transforms if there is a mixin involved\n if (hasMixins && nativeCssVariables && this._applyShim) {\n this._applyShim['transformRules'](ast, elementName);\n }\n template['_styleAst'] = ast;\n template._cssBuild = cssBuild;\n\n let ownPropertyNames = [];\n if (!nativeCssVariables) {\n ownPropertyNames = StyleProperties.decorateStyles(template['_styleAst'], info);\n }\n if (!ownPropertyNames.length || nativeCssVariables) {\n let root = nativeShadow ? template.content : null;\n let placeholder = placeholderMap[elementName];\n let style = this._generateStaticStyle(info, template['_styleAst'], root, placeholder);\n template._style = style;\n }\n template._ownPropertyNames = ownPropertyNames;\n }\n _generateStaticStyle(info, rules, shadowroot, placeholder) {\n let cssText = StyleTransformer.elementStyles(info, rules);\n if (cssText.length) {\n return StyleUtil.applyCss(cssText, info.is, shadowroot, placeholder);\n }\n }\n _prepareHost(host) {\n let {is, typeExtension} = StyleUtil.getIsExtends(host);\n let placeholder = placeholderMap[is];\n let template = templateMap[is];\n let ast;\n let ownStylePropertyNames;\n let cssBuild;\n if (template) {\n ast = template['_styleAst'];\n ownStylePropertyNames = template._ownPropertyNames;\n cssBuild = template._cssBuild;\n }\n return StyleInfo.set(host,\n new StyleInfo(\n ast,\n placeholder,\n ownStylePropertyNames,\n is,\n typeExtension,\n cssBuild\n )\n );\n }\n _ensureApplyShim() {\n if (this._applyShim) {\n return;\n } else if (window.ShadyCSS && window.ShadyCSS.ApplyShim) {\n this._applyShim = window.ShadyCSS.ApplyShim;\n this._applyShim['invalidCallback'] = ApplyShimUtils.invalidate;\n }\n }\n _ensureCustomStyleInterface() {\n if (this._customStyleInterface) {\n return;\n } else if (window.ShadyCSS && window.ShadyCSS.CustomStyleInterface) {\n this._customStyleInterface = /** @type {!CustomStyleInterfaceInterface} */(window.ShadyCSS.CustomStyleInterface);\n /** @type {function(!HTMLStyleElement)} */\n this._customStyleInterface['transformCallback'] = (style) => {this.transformCustomStyleForDocument(style)};\n this._customStyleInterface['validateCallback'] = () => {\n requestAnimationFrame(() => {\n if (this._customStyleInterface['enqueued'] || this._elementsHaveApplied) {\n this.flushCustomStyles();\n }\n })\n };\n }\n }\n _ensure() {\n this._ensureApplyShim();\n this._ensureCustomStyleInterface();\n }\n /**\n * Flush and apply custom styles to document\n */\n flushCustomStyles() {\n this._ensure();\n if (!this._customStyleInterface) {\n return;\n }\n let customStyles = this._customStyleInterface['processStyles']();\n // early return if custom-styles don't need validation\n if (!this._customStyleInterface['enqueued']) {\n return;\n }\n if (!nativeCssVariables) {\n this._updateProperties(this._documentOwner, this._documentOwnerStyleInfo);\n this._applyCustomStyles(customStyles);\n } else {\n this._revalidateCustomStyleApplyShim(customStyles);\n }\n this._customStyleInterface['enqueued'] = false;\n // if custom elements have upgraded and there are no native css variables, we must recalculate the whole tree\n if (this._elementsHaveApplied && !nativeCssVariables) {\n this.styleDocument();\n }\n }\n /**\n * Apply styles for the given element\n *\n * @param {!HTMLElement} host\n * @param {Object=} overrideProps\n */\n styleElement(host, overrideProps) {\n let {is} = StyleUtil.getIsExtends(host);\n let styleInfo = StyleInfo.get(host);\n if (!styleInfo) {\n styleInfo = this._prepareHost(host);\n }\n // Only trip the `elementsHaveApplied` flag if a node other that the root document has `applyStyle` called\n if (!this._isRootOwner(host)) {\n this._elementsHaveApplied = true;\n }\n if (overrideProps) {\n styleInfo.overrideStyleProperties =\n styleInfo.overrideStyleProperties || {};\n Object.assign(styleInfo.overrideStyleProperties, overrideProps);\n }\n if (!nativeCssVariables) {\n this._updateProperties(host, styleInfo);\n if (styleInfo.ownStylePropertyNames && styleInfo.ownStylePropertyNames.length) {\n this._applyStyleProperties(host, styleInfo);\n }\n } else {\n if (styleInfo.overrideStyleProperties) {\n updateNativeProperties(host, styleInfo.overrideStyleProperties);\n }\n let template = templateMap[is];\n // bail early if there is no shadowroot for this element\n if (!template && !this._isRootOwner(host)) {\n return;\n }\n if (template && template._style && !ApplyShimUtils.templateIsValid(template)) {\n // update template\n if (!ApplyShimUtils.templateIsValidating(template)) {\n this._ensure();\n this._applyShim && this._applyShim['transformRules'](template['_styleAst'], is);\n template._style.textContent = StyleTransformer.elementStyles(host, styleInfo.styleRules);\n ApplyShimUtils.startValidatingTemplate(template);\n }\n // update instance if native shadowdom\n if (nativeShadow) {\n let root = host.shadowRoot;\n if (root) {\n let style = root.querySelector('style');\n style.textContent = StyleTransformer.elementStyles(host, styleInfo.styleRules);\n }\n }\n styleInfo.styleRules = template['_styleAst'];\n }\n }\n }\n _styleOwnerForNode(node) {\n let root = node.getRootNode();\n let host = root.host;\n if (host) {\n if (StyleInfo.get(host)) {\n return host;\n } else {\n return this._styleOwnerForNode(host);\n }\n }\n return this._documentOwner;\n }\n _isRootOwner(node) {\n return (node === this._documentOwner);\n }\n _applyStyleProperties(host, styleInfo) {\n let is = StyleUtil.getIsExtends(host).is;\n let cacheEntry = styleCache.fetch(is, styleInfo.styleProperties, styleInfo.ownStylePropertyNames);\n let cachedScopeSelector = cacheEntry && cacheEntry.scopeSelector;\n let cachedStyle = cacheEntry ? cacheEntry.styleElement : null;\n let oldScopeSelector = styleInfo.scopeSelector;\n // only generate new scope if cached style is not found\n styleInfo.scopeSelector = cachedScopeSelector || this._generateScopeSelector(is);\n let style = StyleProperties.applyElementStyle(host, styleInfo.styleProperties, styleInfo.scopeSelector, cachedStyle);\n if (!nativeShadow) {\n StyleProperties.applyElementScopeSelector(host, styleInfo.scopeSelector, oldScopeSelector);\n }\n if (!cacheEntry) {\n styleCache.store(is, styleInfo.styleProperties, style, styleInfo.scopeSelector);\n }\n return style;\n }\n _updateProperties(host, styleInfo) {\n let owner = this._styleOwnerForNode(host);\n let ownerStyleInfo = StyleInfo.get(owner);\n let ownerProperties = ownerStyleInfo.styleProperties;\n let props = Object.create(ownerProperties || null);\n let hostAndRootProps = StyleProperties.hostAndRootPropertiesForScope(host, styleInfo.styleRules);\n let propertyData = StyleProperties.propertyDataFromStyles(ownerStyleInfo.styleRules, host);\n let propertiesMatchingHost = propertyData.properties\n Object.assign(\n props,\n hostAndRootProps.hostProps,\n propertiesMatchingHost,\n hostAndRootProps.rootProps\n );\n this._mixinOverrideStyles(props, styleInfo.overrideStyleProperties);\n StyleProperties.reify(props);\n styleInfo.styleProperties = props;\n }\n _mixinOverrideStyles(props, overrides) {\n for (let p in overrides) {\n let v = overrides[p];\n // skip override props if they are not truthy or 0\n // in order to fall back to inherited values\n if (v || v === 0) {\n props[p] = v;\n }\n }\n }\n /**\n * Update styles of the whole document\n *\n * @param {Object=} properties\n */\n styleDocument(properties) {\n this.styleSubtree(this._documentOwner, properties);\n }\n /**\n * Update styles of a subtree\n *\n * @param {!HTMLElement} host\n * @param {Object=} properties\n */\n styleSubtree(host, properties) {\n let root = host.shadowRoot;\n if (root || this._isRootOwner(host)) {\n this.styleElement(host, properties);\n }\n // process the shadowdom children of `host`\n let shadowChildren = root && (root.children || root.childNodes);\n if (shadowChildren) {\n for (let i = 0; i < shadowChildren.length; i++) {\n let c = /** @type {!HTMLElement} */(shadowChildren[i]);\n this.styleSubtree(c);\n }\n } else {\n // process the lightdom children of `host`\n let children = host.children || host.childNodes;\n if (children) {\n for (let i = 0; i < children.length; i++) {\n let c = /** @type {!HTMLElement} */(children[i]);\n this.styleSubtree(c);\n }\n }\n }\n }\n /* Custom Style operations */\n _revalidateCustomStyleApplyShim(customStyles) {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n let s = this._customStyleInterface['getStyleForCustomStyle'](c);\n if (s) {\n this._revalidateApplyShim(s);\n }\n }\n }\n _applyCustomStyles(customStyles) {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n let s = this._customStyleInterface['getStyleForCustomStyle'](c);\n if (s) {\n StyleProperties.applyCustomStyle(s, this._documentOwnerStyleInfo.styleProperties);\n }\n }\n }\n transformCustomStyleForDocument(style) {\n let ast = StyleUtil.rulesForStyle(style);\n StyleUtil.forEachRule(ast, (rule) => {\n if (nativeShadow) {\n StyleTransformer.normalizeRootSelector(rule);\n } else {\n StyleTransformer.documentRule(rule);\n }\n if (nativeCssVariables) {\n this._ensure();\n this._applyShim && this._applyShim['transformRule'](rule);\n }\n });\n if (nativeCssVariables) {\n style.textContent = StyleUtil.toCssText(ast);\n } else {\n this._documentOwnerStyleInfo.styleRules.rules.push(ast);\n }\n }\n _revalidateApplyShim(style) {\n if (nativeCssVariables && this._applyShim) {\n let ast = StyleUtil.rulesForStyle(style);\n this._ensure();\n this._applyShim['transformRules'](ast);\n style.textContent = StyleUtil.toCssText(ast);\n }\n }\n getComputedStyleValue(element, property) {\n let value;\n if (!nativeCssVariables) {\n // element is either a style host, or an ancestor of a style host\n let styleInfo = StyleInfo.get(element) || StyleInfo.get(this._styleOwnerForNode(element));\n value = styleInfo.styleProperties[property];\n }\n // fall back to the property value from the computed styling\n value = value || window.getComputedStyle(element).getPropertyValue(property);\n // trim whitespace that can come after the `:` in css\n // example: padding: 2px -> \" 2px\"\n return value ? value.trim() : '';\n }\n // given an element and a classString, replaces\n // the element's class with the provided classString and adds\n // any necessary ShadyCSS static and property based scoping selectors\n setElementClass(element, classString) {\n let root = element.getRootNode();\n let classes = classString ? classString.split(/\\s/) : [];\n let scopeName = root.host && root.host.localName;\n // If no scope, try to discover scope name from existing class.\n // This can occur if, for example, a template stamped element that\n // has been scoped is manipulated when not in a root.\n if (!scopeName) {\n var classAttr = element.getAttribute('class');\n if (classAttr) {\n let k$ = classAttr.split(/\\s/);\n for (let i=0; i < k$.length; i++) {\n if (k$[i] === StyleTransformer.SCOPE_NAME) {\n scopeName = k$[i+1];\n break;\n }\n }\n }\n }\n if (scopeName) {\n classes.push(StyleTransformer.SCOPE_NAME, scopeName);\n }\n if (!nativeCssVariables) {\n let styleInfo = StyleInfo.get(element);\n if (styleInfo && styleInfo.scopeSelector) {\n classes.push(StyleProperties.XSCOPE_NAME, styleInfo.scopeSelector);\n }\n }\n StyleUtil.setElementClassRaw(element, classes.join(' '));\n }\n _styleInfoForNode(node) {\n return StyleInfo.get(node);\n }\n}\n\n/* exports */\nScopingShim.prototype['flush'] = ScopingShim.prototype.flush;\nScopingShim.prototype['prepareTemplate'] = ScopingShim.prototype.prepareTemplate;\nScopingShim.prototype['styleElement'] = ScopingShim.prototype.styleElement;\nScopingShim.prototype['styleDocument'] = ScopingShim.prototype.styleDocument;\nScopingShim.prototype['styleSubtree'] = ScopingShim.prototype.styleSubtree;\nScopingShim.prototype['getComputedStyleValue'] = ScopingShim.prototype.getComputedStyleValue;\nScopingShim.prototype['setElementClass'] = ScopingShim.prototype.setElementClass;\nScopingShim.prototype['_styleInfoForNode'] = ScopingShim.prototype._styleInfoForNode;\nScopingShim.prototype['transformCustomStyleForDocument'] = ScopingShim.prototype.transformCustomStyleForDocument;\nScopingShim.prototype['getStyleAst'] = ScopingShim.prototype.getStyleAst;\nScopingShim.prototype['styleAstToString'] = ScopingShim.prototype.styleAstToString;\nScopingShim.prototype['flushCustomStyles'] = ScopingShim.prototype.flushCustomStyles;\nObject.defineProperties(ScopingShim.prototype, {\n 'nativeShadow': {\n get() {\n return nativeShadow;\n }\n },\n 'nativeCss': {\n get() {\n return nativeCssVariables;\n }\n }\n});","/**\n@license\nCopyright (c) 2017 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'use strict';\n\nexport default class StyleCache {\n constructor(typeMax = 100) {\n // map element name -> [{properties, styleElement, scopeSelector}]\n this.cache = {};\n this.typeMax = typeMax;\n }\n\n _validate(cacheEntry, properties, ownPropertyNames) {\n for (let idx = 0; idx < ownPropertyNames.length; idx++) {\n let pn = ownPropertyNames[idx];\n if (cacheEntry.properties[pn] !== properties[pn]) {\n return false;\n }\n }\n return true;\n }\n\n store(tagname, properties, styleElement, scopeSelector) {\n let list = this.cache[tagname] || [];\n list.push({properties, styleElement, scopeSelector});\n if (list.length > this.typeMax) {\n list.shift();\n }\n this.cache[tagname] = list;\n }\n\n fetch(tagname, properties, ownPropertyNames) {\n let list = this.cache[tagname];\n if (!list) {\n return;\n }\n // reverse list for most-recent lookups\n for (let idx = list.length - 1; idx >= 0; idx--) {\n let entry = list[idx];\n if (this._validate(entry, properties, ownPropertyNames)) {\n return entry;\n }\n }\n }\n}\n","/**\n@license\nCopyright (c) 2017 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 { MIXIN_MATCH, VAR_ASSIGN } from './common-regex.js';\n\n/**\n * @param {Element} element\n * @param {Object=} properties\n */\nexport function updateNativeProperties(element, properties) {\n // remove previous properties\n for (let p in properties) {\n // NOTE: for bc with shim, don't apply null values.\n if (p === null) {\n element.style.removeProperty(p);\n } else {\n element.style.setProperty(p, properties[p]);\n }\n }\n}\n\n/**\n * @param {Element} element\n * @param {string} property\n * @return {string}\n */\nexport function getComputedStyleValue(element, property) {\n /**\n * @const {string}\n */\n const value = window.getComputedStyle(element).getPropertyValue(property);\n if (!value) {\n return '';\n } else {\n return value.trim();\n }\n}\n\n/**\n * return true if `cssText` contains a mixin definition or consumption\n * @param {string} cssText\n * @return {boolean}\n */\nexport function detectMixin(cssText) {\n const has = MIXIN_MATCH.test(cssText) || VAR_ASSIGN.test(cssText);\n // reset state of the regexes\n MIXIN_MATCH.lastIndex = 0;\n VAR_ASSIGN.lastIndex = 0;\n return has;\n}\n","/**\n@license\nCopyright (c) 2017 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 ScopingShim from '../src/scoping-shim.js';\nimport {nativeCssVariables, nativeShadow} from '../src/style-settings.js';\n\n/** @const {ScopingShim} */\nconst scopingShim = new ScopingShim();\n\nlet ApplyShim, CustomStyleInterface;\n\nif (window['ShadyCSS']) {\n ApplyShim = window['ShadyCSS']['ApplyShim'];\n CustomStyleInterface = window['ShadyCSS']['CustomStyleInterface'];\n}\n\nwindow.ShadyCSS = {\n ScopingShim: scopingShim,\n /**\n * @param {!HTMLTemplateElement} template\n * @param {string} elementName\n * @param {string=} elementExtends\n */\n prepareTemplate(template, elementName, elementExtends) {\n scopingShim.flushCustomStyles();\n scopingShim.prepareTemplate(template, elementName, elementExtends)\n },\n\n /**\n * @param {!HTMLElement} element\n * @param {Object=} properties\n */\n styleSubtree(element, properties) {\n scopingShim.flushCustomStyles();\n scopingShim.styleSubtree(element, properties);\n },\n\n /**\n * @param {!HTMLElement} element\n */\n styleElement(element) {\n scopingShim.flushCustomStyles();\n scopingShim.styleElement(element);\n },\n\n /**\n * @param {Object=} properties\n */\n styleDocument(properties) {\n scopingShim.flushCustomStyles();\n scopingShim.styleDocument(properties);\n },\n\n /**\n * @param {Element} element\n * @param {string} property\n * @return {string}\n */\n getComputedStyleValue(element, property) {\n return scopingShim.getComputedStyleValue(element, property);\n },\n\n nativeCss: nativeCssVariables,\n\n nativeShadow: nativeShadow\n};\n\nif (ApplyShim) {\n window.ShadyCSS.ApplyShim = ApplyShim;\n}\n\nif (CustomStyleInterface) {\n window.ShadyCSS.CustomStyleInterface = CustomStyleInterface;\n}"]} \ No newline at end of file diff --git a/src/style-properties.js b/src/style-properties.js index 9e89d65..79d863a 100644 --- a/src/style-properties.js +++ b/src/style-properties.js @@ -448,7 +448,10 @@ class StyleProperties { * @param {string} scopeId */ _scopeKeyframes(rule, scopeId) { - rule.keyframesNameRx = new RegExp(rule['keyframesName'], 'g'); + // Animation names are of the form [\w-], so ensure that the name regex does not partially apply + // to similarly named keyframe names by checking for a word boundary at the beginning and + // a non-word boundary or `-` at the end. + rule.keyframesNameRx = new RegExp(`\\b${rule['keyframesName']}(?!\\B|-)`, 'g'); rule.transformedKeyframesName = rule['keyframesName'] + '-' + scopeId; rule.transformedSelector = rule.transformedSelector || rule['selector']; rule['selector'] = rule.transformedSelector.replace( diff --git a/tests/scoping.html b/tests/scoping.html index 757096a..4f749e1 100644 --- a/tests/scoping.html +++ b/tests/scoping.html @@ -385,6 +385,29 @@ + +