diff --git a/.gitignore b/.gitignore index d82160d5242..1afb24e8405 100644 --- a/.gitignore +++ b/.gitignore @@ -54,6 +54,14 @@ pubspec.lock # Vim temporary swap files. *.swp +# Third party files +third_party/nss_pkcs12 +third_party/polymer + # Generated files. tools/out tools/xcodebuild +pkg/shadow_dom/tool/node_modules + + + diff --git a/pkg/shadow_dom/lib/shadow_dom.debug.js b/pkg/shadow_dom/lib/shadow_dom.debug.js index 4ea1ab833ae..eff86b3e6c2 100644 --- a/pkg/shadow_dom/lib/shadow_dom.debug.js +++ b/pkg/shadow_dom/lib/shadow_dom.debug.js @@ -3204,4 +3204,528 @@ var ShadowDOMPolyfill = {}; }; })(); +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +var Platform = {}; + +/* + * Copyright 2012 The Polymer Authors. All rights reserved. + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file. + */ + +/* + This is a limited shim for ShadowDOM css styling. + https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#styles + + The intention here is to support only the styling features which can be + relatively simply implemented. The goal is to allow users to avoid the + most obvious pitfalls and do so without compromising performance significantly. + For ShadowDOM styling that's not covered here, a set of best practices + can be provided that should allow users to accomplish more complex styling. + + The following is a list of specific ShadowDOM styling features and a brief + discussion of the approach used to shim. + + Shimmed features: + + * @host: ShadowDOM allows styling of the shadowRoot's host element using the + @host rule. To shim this feature, the @host styles are reformatted and + prefixed with a given scope name and promoted to a document level stylesheet. + For example, given a scope name of .foo, a rule like this: + + @host { + * { + background: red; + } + } + + becomes: + + .foo { + background: red; + } + + * encapsultion: Styles defined within ShadowDOM, apply only to + dom inside the ShadowDOM. Polymer uses one of two techniques to imlement + this feature. + + By default, rules are prefixed with the host element tag name + as a descendant selector. This ensures styling does not leak out of the 'top' + of the element's ShadowDOM. For example, + + div { + font-weight: bold; + } + + becomes: + + x-foo div { + font-weight: bold; + } + + becomes: + + + Alternatively, if Platform.ShadowCSS.strictStyling is set to true then + selectors are scoped by adding an attribute selector suffix to each + simple selector that contains the host element tag name. Each element + in the element's ShadowDOM template is also given the scope attribute. + Thus, these rules match only elements that have the scope attribute. + For example, given a scope name of x-foo, a rule like this: + + div { + font-weight: bold; + } + + becomes: + + div[x-foo] { + font-weight: bold; + } + + Note that elements that are dynamically added to a scope must have the scope + selector added to them manually. + + * ::pseudo: These rules are converted to rules that take advantage of the + pseudo attribute. For example, a shadowRoot like this inside an x-foo + +
Special
+ + with a rule like this: + + x-foo::x-special { ... } + + becomes: + + x-foo [pseudo=x-special] { ... } + + Unaddressed ShadowDOM styling features: + + * upper/lower bound encapsulation: Styles which are defined outside a + shadowRoot should not cross the ShadowDOM boundary and should not apply + inside a shadowRoot. + + This styling behavior is not emulated. Some possible ways to do this that + were rejected due to complexity and/or performance concerns include: (1) reset + every possible property for every possible selector for a given scope name; + (2) re-implement css in javascript. + + As an alternative, users should make sure to use selectors + specific to the scope in which they are working. + + * ::distributed: This behavior is not emulated. It's often not necessary + to style the contents of a specific insertion point and instead, descendants + of the host element can be styled selectively. Users can also create an + extra node around an insertion point and style that node's contents + via descendent selectors. For example, with a shadowRoot like this: + + + + + could become: + + +
+ +
+ + Note the use of @polyfill in the comment above a ShadowDOM specific style + declaration. This is a directive to the styling shim to use the selector + in comments in lieu of the next selector when running under polyfill. +*/ +(function(scope) { + +var ShadowCSS = { + strictStyling: false, + registry: {}, + // Shim styles for a given root associated with a name and extendsName + // 1. cache root styles by name + // 2. optionally tag root nodes with scope name + // 3. shim polyfill directives /* @polyfill */ + // 4. shim @host and scoping + shimStyling: function(root, name, extendsName) { + if (root) { + // use caching to make working with styles nodes easier and to facilitate + // lookup of extendee + var def = this.registerDefinition(root, name, extendsName); + // find styles and apply shimming... + if (this.strictStyling) { + this.applyScopeToContent(root, name); + } + this.shimPolyfillDirectives(def.rootStyles, name); + this.applyShimming(def.scopeStyles, name); + } + }, + // Shim styles to be placed inside a shadowRoot. + // 1. shim polyfill directives /* @polyfill */ + // 2. shim @host and scoping + shimShadowDOMStyling: function(styles, name) { + this.shimPolyfillDirectives(styles, name); + this.applyShimming(styles, name); + }, + registerDefinition: function(root, name, extendsName) { + var def = this.registry[name] = { + root: root, + name: name, + extendsName: extendsName + } + var styles = root.querySelectorAll('style'); + styles = styles ? Array.prototype.slice.call(styles, 0) : []; + def.rootStyles = styles; + def.scopeStyles = def.rootStyles; + var extendee = this.registry[def.extendsName]; + if (extendee) { + def.scopeStyles = def.scopeStyles.concat(extendee.scopeStyles); + } + return def; + }, + applyScopeToContent: function(root, name) { + if (root) { + // add the name attribute to each node in root. + Array.prototype.forEach.call(root.querySelectorAll('*'), + function(node) { + node.setAttribute(name, ''); + }); + // and template contents too + Array.prototype.forEach.call(root.querySelectorAll('template'), + function(template) { + this.applyScopeToContent(template.content, name); + }, + this); + } + }, + /* + * Process styles to convert native ShadowDOM rules that will trip + * up the css parser; we rely on decorating the stylesheet with comments. + * + * For example, we convert this rule: + * + * (comment start) @polyfill @host g-menu-item (comment end) + * shadow::-webkit-distributed(g-menu-item) { + * + * to this: + * + * scopeName g-menu-item { + * + **/ + shimPolyfillDirectives: function(styles, name) { + if (styles) { + Array.prototype.forEach.call(styles, function(s) { + s.textContent = this.convertPolyfillDirectives(s.textContent, name); + }, this); + } + }, + convertPolyfillDirectives: function(cssText, name) { + var r = '', l = 0, matches, selector; + while (matches = cssPolyfillCommentRe.exec(cssText)) { + r += cssText.substring(l, matches.index); + // remove end comment delimiter (*/) + selector = matches[1].slice(0, -2).replace(hostRe, name); + r += this.scopeSelector(selector, name) + '{'; + l = cssPolyfillCommentRe.lastIndex; + } + r += cssText.substring(l, cssText.length); + return r; + }, + // apply @host and scope shimming + applyShimming: function(styles, name) { + var cssText = this.shimAtHost(styles, name); + cssText += this.shimScoping(styles, name); + addCssToDocument(cssText); + }, + // form: @host { .foo { declarations } } + // becomes: scopeName.foo { declarations } + shimAtHost: function(styles, name) { + if (styles) { + return this.convertAtHostStyles(styles, name); + } + }, + convertAtHostStyles: function(styles, name) { + var cssText = stylesToCssText(styles); + var r = '', l=0, matches; + while (matches = hostRuleRe.exec(cssText)) { + r += cssText.substring(l, matches.index); + r += this.scopeHostCss(matches[1], name); + l = hostRuleRe.lastIndex; + } + r += cssText.substring(l, cssText.length); + var re = new RegExp('^' + name + selectorReSuffix, 'm'); + var cssText = rulesToCss(this.findAtHostRules(cssToRules(r), + re)); + return cssText; + }, + scopeHostCss: function(cssText, name) { + var r = '', matches; + while (matches = selectorRe.exec(cssText)) { + r += this.scopeHostSelector(matches[1], name) +' ' + matches[2] + '\n\t'; + } + return r; + }, + // supports scopig by name and [is=name] syntax + scopeHostSelector: function(selector, name) { + var r = [], parts = selector.split(','), is = '[is=' + name + ']'; + parts.forEach(function(p) { + p = p.trim(); + // selector: *|:scope -> name + if (p.match(hostElementRe)) { + p = p.replace(hostElementRe, name + '$1$3, ' + is + '$1$3'); + // selector: .foo -> name.foo, [bar] -> name[bar] + } else if (p.match(hostFixableRe)) { + p = name + p + ', ' + is + p; + } + r.push(p); + }, this); + return r.join(', '); + }, + // consider styles that do not include component name in the selector to be + // unscoped and in need of promotion; + // for convenience, also consider keyframe rules this way. + findAtHostRules: function(cssRules, matcher) { + return Array.prototype.filter.call(cssRules, + this.isHostRule.bind(this, matcher)); + }, + isHostRule: function(matcher, cssRule) { + return (cssRule.selectorText && cssRule.selectorText.match(matcher)) || + (cssRule.cssRules && this.findAtHostRules(cssRule.cssRules, matcher).length) || + (cssRule.type == CSSRule.WEBKIT_KEYFRAMES_RULE); + }, + /* Ensure styles are scoped. Pseudo-scoping takes a rule like: + * + * .foo {... } + * + * and converts this to + * + * scopeName .foo { ... } + */ + shimScoping: function(styles, name) { + if (styles) { + return this.convertScopedStyles(styles, name); + } + }, + convertScopedStyles: function(styles, name) { + Array.prototype.forEach.call(styles, function(s) { + if (s.parentNode) { + s.parentNode.removeChild(s); + } + }); + var cssText = stylesToCssText(styles).replace(hostRuleRe, ''); + cssText = this.convertPseudos(cssText); + var rules = cssToRules(cssText); + cssText = this.scopeRules(rules, name); + return cssText; + }, + convertPseudos: function(cssText) { + return cssText.replace(cssPseudoRe, ' [pseudo=$1]'); + }, + // change a selector like 'div' to 'name div' + scopeRules: function(cssRules, name) { + var cssText = ''; + Array.prototype.forEach.call(cssRules, function(rule) { + if (rule.selectorText && (rule.style && rule.style.cssText)) { + cssText += this.scopeSelector(rule.selectorText, name, + this.strictStyling) + ' {\n\t'; + cssText += this.propertiesFromRule(rule) + '\n}\n\n'; + } else if (rule.media) { + cssText += '@media ' + rule.media.mediaText + ' {\n'; + cssText += this.scopeRules(rule.cssRules, name); + cssText += '\n}\n\n'; + } else if (rule.cssText) { + cssText += rule.cssText + '\n\n'; + } + }, this); + return cssText; + }, + scopeSelector: function(selector, name, strict) { + var r = [], parts = selector.split(','); + parts.forEach(function(p) { + p = p.trim(); + if (this.selectorNeedsScoping(p, name)) { + p = strict ? this.applyStrictSelectorScope(p, name) : + this.applySimpleSelectorScope(p, name); + } + r.push(p); + }, this); + return r.join(', '); + }, + selectorNeedsScoping: function(selector, name) { + var matchScope = '(' + name + '|\\[is=' + name + '\\])'; + var re = new RegExp('^' + matchScope + selectorReSuffix, 'm'); + return !selector.match(re); + }, + // scope via name and [is=name] + applySimpleSelectorScope: function(selector, name) { + return name + ' ' + selector + ', ' + '[is=' + name + '] ' + selector; + }, + // return a selector with [name] suffix on each simple selector + // e.g. .foo.bar > .zot becomes .foo[name].bar[name] > .zot[name] + applyStrictSelectorScope: function(selector, name) { + var splits = [' ', '>', '+', '~'], + scoped = selector, + attrName = '[' + name + ']'; + splits.forEach(function(sep) { + var parts = scoped.split(sep); + scoped = parts.map(function(p) { + var t = p.trim(); + if (t && (splits.indexOf(t) < 0) && (t.indexOf(attrName) < 0)) { + p = t.replace(/([^:]*)(:*)(.*)/, '$1' + attrName + '$2$3') + } + return p; + }).join(sep); + }); + return scoped; + }, + propertiesFromRule: function(rule) { + var properties = rule.style.cssText; + // TODO(sorvell): Chrome cssom incorrectly removes quotes from the content + // property. (https://code.google.com/p/chromium/issues/detail?id=247231) + if (rule.style.content && !rule.style.content.match(/['"]+/)) { + properties = 'content: \'' + rule.style.content + '\';\n' + + rule.style.cssText.replace(/content:[^;]*;/g, ''); + } + return properties; + } +}; + +var hostRuleRe = /@host[^{]*{(([^}]*?{[^{]*?}[\s\S]*?)+)}/gim, + selectorRe = /([^{]*)({[\s\S]*?})/gim, + hostElementRe = /(.*)((?:\*)|(?:\:scope))(.*)/, + hostFixableRe = /^[.\[:]/, + cssCommentRe = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim, + cssPolyfillCommentRe = /\/\*\s*@polyfill ([^*]*\*+([^/*][^*]*\*+)*\/)([^{]*?){/gim, + cssPseudoRe = /::(x-[^\s{,(]*)/gim, + selectorReSuffix = '([>\\s~+\[.,{:][\\s\\S]*)?$', + hostRe = /@host/gim; + +function stylesToCssText(styles, preserveComments) { + var cssText = ''; + Array.prototype.forEach.call(styles, function(s) { + cssText += s.textContent + '\n\n'; + }); + // strip comments for easier processing + if (!preserveComments) { + cssText = cssText.replace(cssCommentRe, ''); + } + return cssText; +} + +function cssToRules(cssText) { + var style = document.createElement('style'); + style.textContent = cssText; + document.head.appendChild(style); + var rules = style.sheet.cssRules; + style.parentNode.removeChild(style); + return rules; +} + +function rulesToCss(cssRules) { + for (var i=0, css=[]; i < cssRules.length; i++) { + css.push(cssRules[i].cssText); + } + return css.join('\n\n'); +} + +function addCssToDocument(cssText) { + if (cssText) { + getSheet().appendChild(document.createTextNode(cssText)); + } +} + +var sheet; +function getSheet() { + if (!sheet) { + sheet = document.createElement("style"); + sheet.setAttribute('ShadowCSSShim', ''); + } + return sheet; +} + +// add polyfill stylesheet to document +if (window.ShadowDOMPolyfill) { + addCssToDocument('style { display: none !important; }\n'); + var head = document.querySelector('head'); + head.insertBefore(getSheet(), head.childNodes[0]); +} + +// exports +scope.ShadowCSS = ShadowCSS; + +})(window.Platform); +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +(function(scope) { + // TODO(terry): Remove shimShadowDOMStyling2 until wrap/unwrap from a + // dart:html Element to a JS DOM node is available. + /** + * Given the content of a STYLE tag and the name of a component shim the CSS + * and return the new scoped CSS to replace the STYLE's content. The content + * is replaced in Dart's implementation of PolymerElement. + */ + function shimShadowDOMStyling2(styleContent, name) { + if (window.ShadowDOMPolyfill) { + var content = this.convertPolyfillDirectives(styleContent, name); + + // applyShimming calls shimAtHost and shipScoping + // shimAtHost code: + var r = '', l=0, matches; + while (matches = hostRuleRe.exec(content)) { + r += content.substring(l, matches.index); + r += this.scopeHostCss(matches[1], name); + l = hostRuleRe.lastIndex; + } + r += content.substring(l, content.length); + var re = new RegExp('^' + name + selectorReSuffix, 'm'); + var atHostCssText = rulesToCss(this.findAtHostRules(cssToRules(r), re)); + + // shimScoping code: + // strip comments for easier processing + content = content.replace(cssCommentRe, ''); + + content = this.convertPseudos(content); + var rules = cssToRules(content); + var cssText = this.scopeRules(rules, name); + + return atHostCssText + cssText; + } + } + + // Minimal copied code from ShadowCSS, that is not exposed in + // PlatForm.ShadowCSS (local code). + var hostRuleRe = /@host[^{]*{(([^}]*?{[^{]*?}[\s\S]*?)+)}/gim, + cssCommentRe = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim, + selectorReSuffix = '([>\\s~+\[.,{:][\\s\\S]*)?$'; + + function cssToRules(cssText) { + var style = document.createElement('style'); + style.textContent = cssText; + document.head.appendChild(style); + var rules = style.sheet.cssRules; + style.parentNode.removeChild(style); + return rules; + } + + function rulesToCss(cssRules) { + for (var i=0, css=[]; i < cssRules.length; i++) { + css.push(cssRules[i].cssText); + } + return css.join('\n\n'); + } + + // exports + scope.ShadowCSS.shimShadowDOMStyling2 = shimShadowDOMStyling2; +})(window.Platform); + } \ No newline at end of file diff --git a/pkg/shadow_dom/lib/shadow_dom.min.js b/pkg/shadow_dom/lib/shadow_dom.min.js index e9d570e0010..888ec35c3d3 100644 --- a/pkg/shadow_dom/lib/shadow_dom.min.js +++ b/pkg/shadow_dom/lib/shadow_dom.min.js @@ -1,2 +1,2 @@ -if(!HTMLElement.prototype.createShadowRoot&&!HTMLElement.prototype.webkitCreateShadowRoot||window.__forceShadowDomPolyfill){(function(){Element.prototype.webkitCreateShadowRoot&&(Element.prototype.webkitCreateShadowRoot=function(){return window.ShadowDOMPolyfill.wrapIfNeeded(this).createShadowRoot()})})();var SideTable;"undefined"!=typeof WeakMap&&0>navigator.userAgent.indexOf("Firefox/")?SideTable=WeakMap:function(){var e=Object.defineProperty,t=Object.hasOwnProperty,n=(new Date).getTime()%1e9;SideTable=function(){this.name="__st"+(1e9*Math.random()>>>0)+(n++ +"__")},SideTable.prototype={set:function(t,n){e(t,this.name,{value:n,writable:!0})},get:function(e){return t.call(e,this.name)?e[this.name]:void 0},"delete":function(e){this.set(e,void 0)}}}();var ShadowDOMPolyfill={};(function(e){"use strict";function t(e){if(!e)throw new Error("Assertion failed")}function n(e,t){return Object.getOwnPropertyNames(t).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function r(e,t){return Object.getOwnPropertyNames(t).forEach(function(n){switch(n){case"arguments":case"caller":case"length":case"name":case"prototype":case"toString":return}Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function i(e){var t=e.__proto__||Object.getPrototypeOf(e),n=M.get(t);if(n)return n;var r=i(t),o=p(r);return u(t,o,e),o}function o(e,t){l(e,t,!0)}function a(e,t){l(t,e,!1)}function l(e,t,n){Object.getOwnPropertyNames(e).forEach(function(r){if(!(r in t)){L&&e.__lookupGetter__(r);var i;try{i=Object.getOwnPropertyDescriptor(e,r)}catch(o){i=C}var a,l;if(n&&"function"==typeof i.value)return t[r]=function(){return this.impl[r].apply(this.impl,arguments)},void 0;a=function(){return this.impl[r]},(i.writable||i.set)&&(l=function(e){this.impl[r]=e}),Object.defineProperty(t,r,{get:a,set:l,configurable:i.configurable,enumerable:i.enumerable})}})}function s(e,t,n){var i=e.prototype;u(i,t,n),r(t,e)}function u(e,n,r){var i=n.prototype;t(void 0===M.get(e)),M.set(e,n),o(e,i),r&&a(i,r)}function c(e,t){return M.get(t.prototype)===e}function d(e){var t=Object.getPrototypeOf(e),n=i(t),r=p(n);return u(t,r,e),r}function p(e){function t(t){e.call(this,t)}return t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t._ShadowDOMPolyfill$isGeneratedWrapper=!0,t}function h(e){return e instanceof N.EventTarget||e instanceof N.Event||e instanceof N.DOMImplementation}function f(e){return e instanceof D||e instanceof O||e instanceof _||e instanceof H}function m(e){if(null===e)return null;t(f(e));var n=S.get(e);if(!n){var r=i(e);n=new r(e),S.set(e,n)}return n}function g(e){return null===e?null:(t(h(e)),e.impl)}function w(e){return e&&h(e)?g(e):e}function v(e){return e&&!h(e)?m(e):e}function E(e,n){null!==n&&(t(f(e)),t(void 0===n||h(n)),S.set(e,n))}function y(e,t,n){Object.defineProperty(e.prototype,t,{get:n,configurable:!0,enumerable:!0})}function T(e,t){y(e,t,function(){return m(this.impl[t])})}function b(e,t){e.forEach(function(e){t.forEach(function(t){e.prototype[t]=function(){var e=m(this);return e[t].apply(e,arguments)}})})}var S=new SideTable,M=new SideTable,N=Object.create(null);Object.getOwnPropertyNames(window);var L=/Firefox/.test(navigator.userAgent),C={get:function(){},set:function(){},configurable:!0,enumerable:!0},H=DOMImplementation,O=Event,D=Node,_=Window;e.assert=t,e.defineGetter=y,e.defineWrapGetter=T,e.forwardMethodsToWrapper=b,e.isWrapper=h,e.isWrapperFor=c,e.mixin=n,e.registerObject=d,e.registerWrapper=s,e.rewrap=E,e.unwrap=g,e.unwrapIfNeeded=w,e.wrap=m,e.wrapIfNeeded=v,e.wrappers=N})(this.ShadowDOMPolyfill),function(e){"use strict";function t(e){return e instanceof I.ShadowRoot}function n(e){var t=e.localName;return"content"===t||"shadow"===t}function r(e){return!!e.shadowRoot}function i(e){var t;return e.parentNode||(t=e.defaultView)&&R(t)||null}function o(o,a,l){if(l.length)return l.shift();if(t(o))return o.insertionParent||e.getHostForShadowRoot(o);var s=e.eventParentsTable.get(o);if(s){for(var u=1;s.length>u;u++)l[u-1]=s[u];return s[0]}if(a&&n(o)){var c=o.parentNode;if(c&&r(c))for(var d=e.getShadowTrees(c),p=a.insertionParent,u=0;d.length>u;u++)if(d[u].contains(p))return p}return i(o)}function a(e){for(var r=[],i=e,a=[],s=[];i;){var u=null;if(n(i)){u=l(r);var c=r[r.length-1]||i;r.push(c)}else r.length||r.push(i);var d=r[r.length-1];a.push({target:d,currentTarget:i}),t(i)&&r.pop(),i=o(i,u,s)}return a}function l(e){for(var t=e.length-1;t>=0;t--)if(!n(e[t]))return e[t];return null}function s(r,i){for(var a=[];r;){for(var s=[],c=i,p=void 0;c;){var h=null;if(s.length){if(n(c)&&(h=l(s),u(p))){var f=s[s.length-1];s.push(f)}}else s.push(c);if(d(c,r))return s[s.length-1];t(c)&&s.pop(),p=c,c=o(c,h,a)}r=t(r)?e.getHostForShadowRoot(r):r.parentNode}}function u(e){return e.insertionParent}function c(e){for(var t;t=e.parentNode;)e=t;return e}function d(e,t){return c(e)===c(t)}function p(e){switch(e){case"DOMAttrModified":case"DOMAttributeNameChanged":case"DOMCharacterDataModified":case"DOMElementNameChanged":case"DOMNodeInserted":case"DOMNodeInsertedIntoDocument":case"DOMNodeRemoved":case"DOMNodeRemovedFromDocument":case"DOMSubtreeModified":return!0}return!1}function h(t){if(!F.get(t)){F.set(t,!0),p(t.type)||e.renderAllPending();var n=R(t.target),r=R(t);return f(r,n)}}function f(e,t){var n=a(t);return"load"===e.type&&2===n.length&&n[0].target instanceof I.Document&&n.shift(),m(e,n)&&g(e,n)&&w(e,n),k.set(e,y.NONE),W.set(e,null),e.defaultPrevented}function m(e,t){for(var n,r=t.length-1;r>0;r--){var i=t[r].target,o=t[r].currentTarget;if(i!==o&&(n=y.CAPTURING_PHASE,!v(t[r],e,n)))return!1}return!0}function g(e,t){var n=y.AT_TARGET;return v(t[0],e,n)}function w(e,t){for(var n,r=e.bubbles,i=1;t.length>i;i++){var o=t[i].target,a=t[i].currentTarget;if(o===a)n=y.AT_TARGET;else{if(!r||q.get(e))continue;n=y.BUBBLING_PHASE}if(!v(t[i],e,n))return}}function v(e,t,n){var r=e.target,i=e.currentTarget,o=A.get(i);if(!o)return!0;if("relatedTarget"in t){var a=x(t),l=R(a.relatedTarget),u=s(i,l);if(u===r)return!0;B.set(t,u)}k.set(t,n);var c=t.type,d=!1;j.set(t,r),W.set(t,i);for(var p=0;o.length>p;p++){var h=o[p];if(h.removed)d=!0;else if(!(h.type!==c||!h.capture&&n===y.CAPTURING_PHASE||h.capture&&n===y.BUBBLING_PHASE))try{if("function"==typeof h.handler?h.handler.call(i,t):h.handler.handleEvent(t),q.get(t))return!1}catch(f){window.onerror?window.onerror(f.message):console.error(f)}}if(d){var m=o.slice();o.length=0;for(var p=0;m.length>p;p++)m[p].removed||o.push(m[p])}return!G.get(t)}function E(e,t,n){this.type=e,this.handler=t,this.capture=Boolean(n)}function y(e,t){return e instanceof U?(this.impl=e,void 0):R(M(U,"Event",e,t))}function T(e){return e&&e.relatedTarget?Object.create(e,{relatedTarget:{value:x(e.relatedTarget)}}):e}function b(e,t,n){var r=window[e],i=function(t,n){return t instanceof r?(this.impl=t,void 0):R(M(r,e,t,n))};return i.prototype=Object.create(t.prototype),n&&_(i.prototype,n),r&&P(r,i,document.createEvent(e)),i}function S(e,t){return function(){arguments[t]=x(arguments[t]);var n=x(this);n[e].apply(n,arguments)}}function M(e,t,n,r){if(et)return new e(n,T(r));var i=x(document.createEvent(t)),o=J[t],a=[n];return Object.keys(o).forEach(function(e){var t=null!=r&&e in r?r[e]:o[e];"relatedTarget"===e&&(t=x(t)),a.push(t)}),i["init"+t].apply(i,a),i}function N(e){return"function"==typeof e?!0:e&&e.handleEvent}function L(e){this.impl=e}function C(t){return t instanceof I.ShadowRoot&&(t=e.getHostForShadowRoot(t)),x(t)}function H(e){D(e,rt)}function O(t,n,r,i){e.renderAllPending();for(var o=R(it.call(n.impl,r,i)),l=a(o,this),s=0;l.length>s;s++){var u=l[s];if(u.currentTarget===t)return u.target}return null}var D=e.forwardMethodsToWrapper,_=e.mixin,P=e.registerWrapper,x=e.unwrap,R=e.wrap,I=e.wrappers;new SideTable;var A=new SideTable,F=new SideTable,j=new SideTable,W=new SideTable,B=new SideTable,k=new SideTable,G=new SideTable,q=new SideTable;E.prototype={equals:function(e){return this.handler===e.handler&&this.type===e.type&&this.capture===e.capture},get removed(){return null===this.handler},remove:function(){this.handler=null}};var U=window.Event;y.prototype={get target(){return j.get(this)},get currentTarget(){return W.get(this)},get eventPhase(){return k.get(this)},stopPropagation:function(){G.set(this,!0)},stopImmediatePropagation:function(){G.set(this,!0),q.set(this,!0)}},P(U,y,document.createEvent("Event"));var V=b("UIEvent",y),K=b("CustomEvent",y),$={get relatedTarget(){return B.get(this)||R(x(this).relatedTarget)}},z=_({initMouseEvent:S("initMouseEvent",14)},$),X=_({initFocusEvent:S("initFocusEvent",5)},$),Y=b("MouseEvent",V,z),Q=b("FocusEvent",V,X),Z=b("MutationEvent",y,{initMutationEvent:S("initMutationEvent",3),get relatedNode(){return R(this.impl.relatedNode)}}),J=Object.create(null),et=function(){try{new window.MouseEvent("click")}catch(e){return!1}return!0}();if(!et){var tt=function(e,t,n){if(n){var r=J[n];t=_(_({},r),t)}J[e]=t};tt("Event",{bubbles:!1,cancelable:!1}),tt("CustomEvent",{detail:null},"Event"),tt("UIEvent",{view:null,detail:0},"Event"),tt("MouseEvent",{screenX:0,screenY:0,clientX:0,clientY:0,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,button:0,relatedTarget:null},"UIEvent"),tt("FocusEvent",{relatedTarget:null},"UIEvent")}var nt=window.EventTarget,rt=["addEventListener","removeEventListener","dispatchEvent"];[Element,Window,Document].forEach(function(e){var t=e.prototype;rt.forEach(function(e){Object.defineProperty(t,e+"_",{value:t[e]})})}),L.prototype={addEventListener:function(e,t,n){if(N(t)){var r=new E(e,t,n),i=A.get(this);if(i){for(var o=0;i.length>o;o++)if(r.equals(i[o]))return}else i=[],A.set(this,i);i.push(r);var a=C(this);a.addEventListener_(e,h,!0)}},removeEventListener:function(e,t,n){n=Boolean(n);var r=A.get(this);if(r){for(var i=0,o=!1,a=0;r.length>a;a++)r[a].type===e&&r[a].capture===n&&(i++,r[a].handler===t&&(o=!0,r[a].remove()));if(o&&1===i){var l=C(this);l.removeEventListener_(e,h,!0)}}},dispatchEvent:function(t){e.renderAllPending();var n=C(this);return n.dispatchEvent_(x(t))}},nt&&P(nt,L);var it=document.elementFromPoint;e.adjustRelatedTarget=s,e.elementFromPoint=O,e.wrapEventTargetMethods=H,e.wrappers.CustomEvent=K,e.wrappers.Event=y,e.wrappers.EventTarget=L,e.wrappers.FocusEvent=Q,e.wrappers.MouseEvent=Y,e.wrappers.MutationEvent=Z,e.wrappers.UIEvent=V}(this.ShadowDOMPolyfill),function(e){"use strict";function t(e,t){Object.defineProperty(e,t,{enumerable:!1})}function n(){this.length=0,t(this,"length")}function r(e){if(null==e)return e;for(var t=new n,r=0,i=e.length;i>r;r++)t[r]=o(e[r]);return t.length=i,t}function i(e,t){e.prototype[t]=function(){return r(this.impl[t].apply(this.impl,arguments))}}var o=e.wrap;n.prototype={item:function(e){return this[e]}},t(n.prototype,"item"),e.wrappers.NodeList=n,e.addWrapNodeListMethod=i,e.wrapNodeList=r}(this.ShadowDOMPolyfill),function(e){"use strict";function t(e){s(e instanceof o)}function n(e,t,n,r){if(e.nodeType!==o.DOCUMENT_FRAGMENT_NODE)return e.parentNode&&e.parentNode.removeChild(e),e.parentNode_=t,e.previousSibling_=n,e.nextSibling_=r,n&&(n.nextSibling_=e),r&&(r.previousSibling_=e),[e];for(var i,a=[];i=e.firstChild;)e.removeChild(i),a.push(i),i.parentNode_=t;for(var l=0;a.length>l;l++)a[l].previousSibling_=a[l-1]||n,a[l].nextSibling_=a[l+1]||r;return n&&(n.nextSibling_=a[0]),r&&(r.previousSibling_=a[a.length-1]),a}function r(e){if(1===e.length)return d(e[0]);for(var t=d(document.createDocumentFragment()),n=0;e.length>n;n++)t.appendChild(d(e[n]));return t}function i(e){for(var t=e.firstChild;t;){s(t.parentNode===e);var n=t.nextSibling,r=d(t),i=r.parentNode;i&&w.call(i,r),t.previousSibling_=t.nextSibling_=t.parentNode_=null,t=n}e.firstChild_=e.lastChild_=null}function o(e){s(e instanceof h),a.call(this,e),this.parentNode_=void 0,this.firstChild_=void 0,this.lastChild_=void 0,this.nextSibling_=void 0,this.previousSibling_=void 0}var a=e.wrappers.EventTarget,l=e.wrappers.NodeList;e.defineWrapGetter;var s=e.assert,u=e.mixin,c=e.registerWrapper,d=e.unwrap,p=e.wrap,h=window.Node,f=h.prototype.appendChild,m=h.prototype.insertBefore,g=h.prototype.replaceChild,w=h.prototype.removeChild,v=h.prototype.compareDocumentPosition;o.prototype=Object.create(a.prototype),u(o.prototype,{appendChild:function(e){t(e),this.invalidateShadowRenderer();var i=this.lastChild,o=null,a=n(e,this,i,o);return this.lastChild_=a[a.length-1],i||(this.firstChild_=a[0]),f.call(this.impl,r(a)),e},insertBefore:function(e,i){if(!i)return this.appendChild(e);t(e),t(i),s(i.parentNode===this),this.invalidateShadowRenderer();var o=i.previousSibling,a=i,l=n(e,this,o,a);this.firstChild===i&&(this.firstChild_=l[0]);var u=d(i),c=u.parentNode;return c&&m.call(c,r(l),u),e},removeChild:function(e){if(t(e),e.parentNode!==this)throw new Error("NotFoundError");this.invalidateShadowRenderer();var n=this.firstChild,r=this.lastChild,i=e.nextSibling,o=e.previousSibling,a=d(e),l=a.parentNode;return l&&w.call(l,a),n===e&&(this.firstChild_=i),r===e&&(this.lastChild_=o),o&&(o.nextSibling_=i),i&&(i.previousSibling_=o),e.previousSibling_=e.nextSibling_=e.parentNode_=null,e},replaceChild:function(e,i){if(t(e),t(i),i.parentNode!==this)throw new Error("NotFoundError");this.invalidateShadowRenderer();var o=i.previousSibling,a=i.nextSibling;a===e&&(a=e.nextSibling);var l=n(e,this,o,a);this.firstChild===i&&(this.firstChild_=l[0]),this.lastChild===i&&(this.lastChild_=l[l.length-1]),i.previousSibling_=null,i.nextSibling_=null,i.parentNode_=null;var s=d(i);return s.parentNode&&g.call(s.parentNode,r(l),s),i},hasChildNodes:function(){return null===this.firstChild},get parentNode(){return void 0!==this.parentNode_?this.parentNode_:p(this.impl.parentNode)},get firstChild(){return void 0!==this.firstChild_?this.firstChild_:p(this.impl.firstChild)},get lastChild(){return void 0!==this.lastChild_?this.lastChild_:p(this.impl.lastChild)},get nextSibling(){return void 0!==this.nextSibling_?this.nextSibling_:p(this.impl.nextSibling)},get previousSibling(){return void 0!==this.previousSibling_?this.previousSibling_:p(this.impl.previousSibling)},get parentElement(){for(var e=this.parentNode;e&&e.nodeType!==o.ELEMENT_NODE;)e=e.parentNode;return e},get textContent(){for(var e="",t=this.firstChild;t;t=t.nextSibling)e+=t.textContent;return e},set textContent(e){if(i(this),this.invalidateShadowRenderer(),""!==e){var t=this.impl.ownerDocument.createTextNode(e);this.appendChild(t)}},get childNodes(){for(var e=new l,t=0,n=this.firstChild;n;n=n.nextSibling)e[t++]=n;return e.length=t,e},cloneNode:function(e){if(!this.invalidateShadowRenderer())return p(this.impl.cloneNode(e));var t=p(this.impl.cloneNode(!1));if(e)for(var n=this.firstChild;n;n=n.nextSibling)t.appendChild(n.cloneNode(!0));return t},contains:function(e){if(!e)return!1;if(e===this)return!0;var t=e.parentNode;return t?this.contains(t):!1},compareDocumentPosition:function(e){return v.call(this.impl,d(e))},get ownerDocument(){return e.renderAllPending(),p(this.impl.ownerDocument)}}),c(h,o,document.createDocumentFragment()),delete o.prototype.querySelector,delete o.prototype.querySelectorAll,o.prototype=u(Object.create(a.prototype),o.prototype),e.wrappers.Node=o}(this.ShadowDOMPolyfill),function(e){"use strict";function t(e,n){for(var r,i=e.firstElementChild;i;){if(i.matches(n))return i;if(r=t(i,n))return r;i=i.nextElementSibling}return null}function n(e,t,r){for(var i=e.firstElementChild;i;)i.matches(t)&&(r[r.length++]=i),n(i,t,r),i=i.nextElementSibling;return r}var r={querySelector:function(e){return t(this,e)},querySelectorAll:function(e){return n(this,e,new NodeList)}},i={getElementsByTagName:function(e){return this.querySelectorAll(e)},getElementsByClassName:function(e){return this.querySelectorAll("."+e)},getElementsByTagNameNS:function(e,t){if("*"===e)return this.getElementsByTagName(t);for(var n=new NodeList,r=this.getElementsByTagName(t),i=0,o=0;r.length>i;i++)r[i].namespaceURI===e&&(n[o++]=r[i]);return n.length=o,n}};e.GetElementsByInterface=i,e.SelectorsInterface=r}(this.ShadowDOMPolyfill),function(e){"use strict";function t(e){for(;e&&e.nodeType!==Node.ELEMENT_NODE;)e=e.nextSibling;return e}function n(e){for(;e&&e.nodeType!==Node.ELEMENT_NODE;)e=e.previousSibling;return e}var r=e.wrappers.NodeList,i={get firstElementChild(){return t(this.firstChild)},get lastElementChild(){return n(this.lastChild)},get childElementCount(){for(var e=0,t=this.firstElementChild;t;t=t.nextElementSibling)e++;return e},get children(){for(var e=new r,t=0,n=this.firstElementChild;n;n=n.nextElementSibling)e[t++]=n;return e.length=t,e}},o={get nextElementSibling(){return t(this.nextSibling)},get previousElementSibling(){return n(this.nextSibling)}};e.ChildNodeInterface=o,e.ParentNodeInterface=i}(this.ShadowDOMPolyfill),function(e){"use strict";function t(e){r.call(this,e)}var n=e.ChildNodeInterface,r=e.wrappers.Node,i=e.mixin,o=e.registerWrapper,a=window.CharacterData;t.prototype=Object.create(r.prototype),i(t.prototype,{get textContent(){return this.data},set textContent(e){this.data=e}}),i(t.prototype,n),o(a,t,document.createTextNode("")),e.wrappers.CharacterData=t}(this.ShadowDOMPolyfill),function(e){"use strict";function t(e){i.call(this,e)}var n=e.ChildNodeInterface,r=e.GetElementsByInterface,i=e.wrappers.Node,o=e.ParentNodeInterface,a=e.SelectorsInterface;e.addWrapNodeListMethod;var l=e.mixin,s=e.registerWrapper,u=e.wrappers,c=new SideTable,d=window.Element,p=d.prototype.matches||d.prototype.mozMatchesSelector||d.prototype.msMatchesSelector||d.prototype.webkitMatchesSelector;t.prototype=Object.create(i.prototype),l(t.prototype,{createShadowRoot:function(){var t=new u.ShadowRoot(this);return c.set(this,t),e.getRendererForHost(this),this.invalidateShadowRenderer(!0),t},get shadowRoot(){return c.get(this)||null},setAttribute:function(e,t){this.impl.setAttribute(e,t),this.invalidateShadowRenderer()},matches:function(e){return p.call(this.impl,e)}}),l(t.prototype,n),l(t.prototype,r),l(t.prototype,o),l(t.prototype,a),s(d,t),e.wrappers.Element=t}(this.ShadowDOMPolyfill),function(e){"use strict";function t(e){switch(e){case"&":return"&";case"<":return"<";case'"':return"""}}function n(e){return e.replace(m,t)}function r(e){switch(e.nodeType){case Node.ELEMENT_NODE:for(var t,r=e.tagName.toLowerCase(),o="<"+r,a=e.attributes,l=0;t=a[l];l++)o+=" "+t.name+'="'+n(t.value)+'"';return o+=">",g[r]?o:o+i(e)+"";case Node.TEXT_NODE:return n(e.nodeValue);case Node.COMMENT_NODE:return"";default:throw console.error(e),new Error("not implemented")}}function i(e){for(var t="",n=e.firstChild;n;n=n.nextSibling)t+=r(n);return t}function o(e,t,n){var r=n||"div";e.textContent="";var i=h(e.ownerDocument.createElement(r));i.innerHTML=t;for(var o;o=i.firstChild;)e.appendChild(f(o))}function a(e){u.call(this,e)}function l(t){c(a,t,function(){return e.renderAllPending(),this.impl[t]})}function s(t){Object.defineProperty(a.prototype,t,{value:function(){return e.renderAllPending(),this.impl[t].apply(this.impl,arguments)},configurable:!0,enumerable:!0})}var u=e.wrappers.Element,c=e.defineGetter,d=e.mixin,p=e.registerWrapper,h=e.unwrap,f=e.wrap,m=/&|<|"/g,g={area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},w=window.HTMLElement;a.prototype=Object.create(u.prototype),d(a.prototype,{get innerHTML(){return i(this)},set innerHTML(e){o(this,e,this.tagName)},get outerHTML(){return r(this)},set outerHTML(e){if(this.invalidateShadowRenderer())throw new Error("not implemented");this.impl.outerHTML=e}}),["clientHeight","clientLeft","clientTop","clientWidth","offsetHeight","offsetLeft","offsetTop","offsetWidth","scrollHeight","scrollLeft","scrollTop","scrollWidth"].forEach(l),["getBoundingClientRect","getClientRects","scrollIntoView"].forEach(s),p(w,a,document.createElement("b")),e.wrappers.HTMLElement=a,e.getInnerHTML=i,e.setInnerHTML=o}(this.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.HTMLElement,r=e.mixin,i=e.registerWrapper,o=window.HTMLContentElement;t.prototype=Object.create(n.prototype),r(t.prototype,{get select(){return this.getAttribute("select")},set select(e){this.setAttribute("select",e)},setAttribute:function(e,t){n.prototype.setAttribute.call(this,e,t),"select"===String(e).toLowerCase()&&this.invalidateShadowRenderer(!0)}}),o&&i(o,t),e.wrappers.HTMLContentElement=t}(this.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e),this.olderShadowRoot_=null}var n=e.wrappers.HTMLElement,r=e.mixin,i=e.registerWrapper,o=window.HTMLShadowElement;t.prototype=Object.create(n.prototype),r(t.prototype,{get olderShadowRoot(){return this.olderShadowRoot_},invalidateShadowRenderer:function(){n.prototype.invalidateShadowRenderer.call(this,!0)}}),o&&i(o,t),e.wrappers.HTMLShadowElement=t}(this.ShadowDOMPolyfill),function(e){"use strict";function t(e){if(!e.defaultView)return e;var t=d.get(e);if(!t){for(t=e.implementation.createHTMLDocument("");t.lastChild;)t.removeChild(t.lastChild);d.set(e,t)}return t}function n(e){for(var n,r=t(e.ownerDocument),i=r.createDocumentFragment();n=e.firstChild;)i.appendChild(n);return i}function r(e){i.call(this,e)}var i=e.wrappers.HTMLElement,o=e.getInnerHTML,a=e.mixin,l=e.registerWrapper,s=e.setInnerHTML,u=e.wrap,c=new SideTable,d=new SideTable,p=window.HTMLTemplateElement;r.prototype=Object.create(i.prototype),a(r.prototype,{get content(){if(p)return u(this.impl.content);var e=c.get(this);return e||(e=n(this),c.set(this,e)),e},get innerHTML(){return o(this.content)},set innerHTML(e){s(this.content,e),this.invalidateShadowRenderer()}}),p&&l(p,r),e.wrappers.HTMLTemplateElement=r}(this.ShadowDOMPolyfill),function(e){"use strict";function t(e){switch(e.localName){case"content":return new n(e);case"shadow":return new i(e);case"template":return new o(e)}r.call(this,e)}var n=e.wrappers.HTMLContentElement,r=e.wrappers.HTMLElement,i=e.wrappers.HTMLShadowElement,o=e.wrappers.HTMLTemplateElement;e.mixin;var a=e.registerWrapper,l=window.HTMLUnknownElement;t.prototype=Object.create(r.prototype),a(l,t),e.wrappers.HTMLUnknownElement=t}(this.ShadowDOMPolyfill),function(e){"use strict";var t=e.GetElementsByInterface,n=e.ParentNodeInterface,r=e.SelectorsInterface,i=e.mixin,o=e.registerObject,a=o(document.createDocumentFragment());i(a.prototype,n),i(a.prototype,r),i(a.prototype,t);var l=o(document.createTextNode("")),s=o(document.createComment(""));e.wrappers.Comment=s,e.wrappers.DocumentFragment=a,e.wrappers.Text=l}(this.ShadowDOMPolyfill),function(e){"use strict";function t(t){var r=s(t.impl.ownerDocument.createDocumentFragment());n.call(this,r),a(r,this);var i=t.shadowRoot;e.nextOlderShadowTreeTable.set(this,i),u.set(this,t)}var n=e.wrappers.DocumentFragment,r=e.elementFromPoint,i=e.getInnerHTML,o=e.mixin,a=e.rewrap,l=e.setInnerHTML,s=e.unwrap,u=new SideTable;t.prototype=Object.create(n.prototype),o(t.prototype,{get innerHTML(){return i(this)},set innerHTML(e){l(this,e),this.invalidateShadowRenderer()},invalidateShadowRenderer:function(){return u.get(this).invalidateShadowRenderer()},elementFromPoint:function(e,t){return r(this,this.ownerDocument,e,t)},getElementById:function(e){return this.querySelector("#"+e)}}),e.wrappers.ShadowRoot=t,e.getHostForShadowRoot=function(e){return u.get(e)}}(this.ShadowDOMPolyfill),function(e){"use strict";function t(e){e.previousSibling_=e.previousSibling,e.nextSibling_=e.nextSibling,e.parentNode_=e.parentNode}function n(e){e.firstChild_=e.firstChild,e.lastChild_=e.lastChild}function r(e){_(e instanceof D);for(var r=e.firstChild;r;r=r.nextSibling)t(r);n(e)}function i(e){var t=x(e);r(e),t.textContent=""}function o(e,n){var i=x(e),o=x(n);o.nodeType===D.DOCUMENT_FRAGMENT_NODE?r(n):(l(n),t(n)),e.lastChild_=e.lastChild,e.lastChild===e.firstChild&&(e.firstChild_=e.firstChild);var a=R(i.lastChild);a&&(a.nextSibling_=a.nextSibling),i.appendChild(o)}function a(e,n){var r=x(e),i=x(n);t(n),n.previousSibling&&(n.previousSibling.nextSibling_=n),n.nextSibling&&(n.nextSibling.previousSibling_=n),e.lastChild===n&&(e.lastChild_=n),e.firstChild===n&&(e.firstChild_=n),r.removeChild(i)}function l(e){var t=x(e),n=t.parentNode;n&&a(R(n),e)}function s(e,t){c(t).push(e),F.set(e,t);var n=A.get(e);n||A.set(e,n=[]),n.push(t)}function u(e){I.set(e,[])}function c(e){return I.get(e)}function d(e){for(var t=[],n=0,r=e.firstChild;r;r=r.nextSibling)t[n++]=r;return t}function p(e,t,n){for(var r=d(e),i=0;r.length>i;i++){var o=r[i];if(t(o)){if(n(o)===!1)return}else p(o,t,n)}}function h(e,t){var n=!1;return p(e,y,function(e){u(e);for(var r=0;t.length>r;r++){var i=t[r];void 0!==i&&m(i,e)&&(s(i,e),t[r]=void 0,n=!0)}}),n?t.filter(function(e){return void 0!==e}):t}function f(e,t){for(var n=0;t.length>n;n++)if(t[n]in e)return t[n]}function m(e,t){var n=t.getAttribute("select");if(!n)return!0;if(n=n.trim(),!n)return!0;if(e.nodeType!==D.ELEMENT_NODE)return!1;if(!k.test(n))return!1;if(":"===n[0]&&!G.test(n))return!1;try{return e.matches(n)}catch(r){return!1}}function g(){H=null,U.forEach(function(e){e.render()}),U=[]}function w(e){this.host=e,this.dirty=!1,this.associateNode(e)}function v(e){var t=W.get(e);return t||(t=new w(e),W.set(e,t)),t}function E(e){return"content"===e.localName}function y(e){return"content"===e.localName}function T(e){return"shadow"===e.localName}function b(e){return"shadow"===e.localName}function S(e){return!!e.shadowRoot}function M(e){return j.get(e)}function N(e){for(var t=[],n=e.shadowRoot;n;n=j.get(n))t.push(n);return t}function L(e,t){F.set(e,t)}function C(e){new w(e).render()}var H,O=e.wrappers.HTMLContentElement,D=e.wrappers.Node,_=e.assert,P=e.mixin,x=e.unwrap,R=e.wrap,I=new SideTable,A=new SideTable,F=new SideTable,j=new SideTable,W=new SideTable,B=new SideTable,k=/^[*.:#[a-zA-Z_|]/,G=new RegExp("^:("+["link","visited","target","enabled","disabled","checked","indeterminate","nth-child","nth-last-child","nth-of-type","nth-last-of-type","first-child","last-child","first-of-type","last-of-type","only-of-type"].join("|")+")"),q=f(window,["requestAnimationFrame","mozRequestAnimationFrame","webkitRequestAnimationFrame","setTimeout"]),U=[];w.prototype={render:function(){if(this.dirty){var e=this.host;this.treeComposition();var t=e.shadowRoot;if(t){this.removeAllChildNodes(this.host);var n=d(t);n.forEach(function(n){this.renderNode(e,t,n,!1)},this),this.dirty=!1}}},invalidate:function(){if(!this.dirty){if(this.dirty=!0,U.push(this),H)return;H=window[q](g,0)}},renderNode:function(e,t,n,r){if(S(n)){this.appendChild(e,n);var i=v(n);i.dirty=!0,i.render()}else E(n)?this.renderInsertionPoint(e,t,n,r):T(n)?this.renderShadowInsertionPoint(e,t,n):this.renderAsAnyDomTree(e,t,n,r)},renderAsAnyDomTree:function(e,t,n,r){if(this.appendChild(e,n),S(n))C(n);else{var i=n,o=d(i);o.forEach(function(e){this.renderNode(i,t,e,r)},this)}},renderInsertionPoint:function(e,t,n,r){var i=c(n);i.length?(this.removeAllChildNodes(n),i.forEach(function(n){E(n)&&r?this.renderInsertionPoint(e,t,n,r):this.renderAsAnyDomTree(e,t,n,r)},this)):this.renderFallbackContent(e,n),this.remove(n)},renderShadowInsertionPoint:function(e,t,n){var r=M(t);if(r){F.set(r,n),n.olderShadowRoot_=r,this.remove(n);var i=d(r);i.forEach(function(t){this.renderNode(e,r,t,!0)},this)}else this.renderFallbackContent(e,n)},renderFallbackContent:function(e,t){var n=d(t);n.forEach(function(t){this.appendChild(e,t)},this)},treeComposition:function(){var e=this.host,t=e.shadowRoot,n=[],r=d(e);r.forEach(function(e){if(E(e)){var t=c(e);t&&t.length||(t=d(e)),n.push.apply(n,t)}else n.push(e)});for(var i,o;t;){if(i=void 0,p(t,b,function(e){return i=e,!1}),o=i,n=h(t,n),o){var a=M(t);if(a){t=a,L(t,o);continue}break}break}},appendChild:function(e,t){o(e,t),this.associateNode(t)},remove:function(e){l(e),this.associateNode(e)},removeAllChildNodes:function(e){i(e)},associateNode:function(e){B.set(e,this)}},D.prototype.invalidateShadowRenderer=function(e){var t=B.get(this);if(!t)return!1;var n;return(e||this.shadowRoot||(n=this.parentNode)&&(n.shadowRoot||n instanceof ShadowRoot))&&t.invalidate(),!0},O.prototype.getDistributedNodes=function(){return g(),c(this)},P(D.prototype,{get insertionParent(){return F.get(this)||null}}),e.eventParentsTable=A,e.getRendererForHost=v,e.getShadowTrees=N,e.nextOlderShadowTreeTable=j,e.renderAllPending=g,e.visual={removeAllChildNodes:i,appendChild:o,removeChild:a}}(this.ShadowDOMPolyfill),function(e){"use strict";function t(e){l.call(this,e)}function n(e){var n=document[e];t.prototype[e]=function(){return g(n.apply(this.impl,arguments))}}function r(e){this.impl=e}function i(e,t){var n=document.implementation[t];e.prototype[t]=function(){return g(n.apply(this.impl,arguments))}}function o(e,t){var n=document.implementation[t];e.prototype[t]=function(){return n.apply(this.impl,arguments)}}var a=e.GetElementsByInterface,l=e.wrappers.Node,s=e.ParentNodeInterface,u=e.SelectorsInterface,c=e.defineWrapGetter,d=e.elementFromPoint,p=e.forwardMethodsToWrapper,h=e.mixin,f=e.registerWrapper,m=e.unwrap,g=e.wrap,w=e.wrapEventTargetMethods;e.wrapNodeList;var v=new SideTable;t.prototype=Object.create(l.prototype),c(t,"documentElement"),c(t,"body"),c(t,"head"),["getElementById","createElement","createElementNS","createTextNode","createDocumentFragment","createEvent","createEventNS"].forEach(n);var E=document.adoptNode,y=document.write;h(t.prototype,{adoptNode:function(e){return E.call(this.impl,m(e)),e},elementFromPoint:function(e,t){return d(this,this,e,t)},write:function(e){for(var t=this.querySelectorAll("*"),n=t[t.length-1];n.nextSibling;)n=n.nextSibling;var r=n.parentNode;r.lastChild_=void 0,n.nextSibling_=void 0,y.call(this.impl,e)}}),p([window.HTMLBodyElement,window.HTMLDocument||window.Document,window.HTMLHeadElement],["appendChild","compareDocumentPosition","getElementsByClassName","getElementsByTagName","getElementsByTagNameNS","insertBefore","querySelector","querySelectorAll","removeChild","replaceChild"]),p([window.HTMLDocument||window.Document],["adoptNode","createDocumentFragment","createElement","createElementNS","createEvent","createEventNS","createTextNode","elementFromPoint","getElementById","write"]),h(t.prototype,a),h(t.prototype,s),h(t.prototype,u),h(t.prototype,{get implementation(){var e=v.get(this);return e?e:(e=new r(m(this).implementation),v.set(this,e),e)}}),f(window.Document,t,document.implementation.createHTMLDocument("")),window.HTMLDocument&&f(window.HTMLDocument,t),w([window.HTMLBodyElement,window.HTMLDocument||window.Document,window.HTMLHeadElement]),i(r,"createDocumentType"),i(r,"createDocument"),i(r,"createHTMLDocument"),o(r,"hasFeature"),f(window.DOMImplementation,r),p([window.DOMImplementation],["createDocumentType","createDocument","createHTMLDocument","hasFeature"]),e.wrappers.Document=t,e.wrappers.DOMImplementation=r}(this.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.EventTarget,r=e.mixin,i=e.registerWrapper,o=e.unwrap,a=e.unwrapIfNeeded,l=e.wrap,s=window.Window;t.prototype=Object.create(n.prototype);var u=window.getComputedStyle;s.prototype.getComputedStyle=function(e,t){return u.call(this||window,a(e),t)},["addEventListener","removeEventListener","dispatchEvent"].forEach(function(e){s.prototype[e]=function(){var t=l(this||window);return t[e].apply(t,arguments)}}),r(t.prototype,{getComputedStyle:function(e,t){return u.call(o(this),a(e),t)}}),i(s,t),e.wrappers.Window=t}(this.ShadowDOMPolyfill),function(e){"use strict";function t(e){this.impl=e}function n(e){return new t(e)}function r(e){return e.map(n)}function i(e){var t=this;this.impl=new c(function(n){e.call(t,r(n),t)})}var o=e.defineGetter,a=e.defineWrapGetter,l=e.registerWrapper,s=e.unwrapIfNeeded,u=e.wrapNodeList;e.wrappers;var c=window.MutationObserver||window.WebKitMutationObserver;if(c){var d=window.MutationRecord;t.prototype={get addedNodes(){return u(this.impl.addedNodes)},get removedNodes(){return u(this.impl.removedNodes)}},["target","previousSibling","nextSibling"].forEach(function(e){a(t,e)}),["type","attributeName","attributeNamespace","oldValue"].forEach(function(e){o(t,e,function(){return this.impl[e] -})}),d&&l(d,t),window.Node,i.prototype={observe:function(e,t){this.impl.observe(s(e),t)},disconnect:function(){this.impl.disconnect()},takeRecords:function(){return r(this.impl.takeRecords())}},e.wrappers.MutationObserver=i,e.wrappers.MutationRecord=t}}(this.ShadowDOMPolyfill),function(e){"use strict";function t(e){var t=n[e],r=window[t];if(r){var i=document.createElement(e),o=i.constructor;window[t]=o}}e.isWrapperFor;var n={a:"HTMLAnchorElement",applet:"HTMLAppletElement",area:"HTMLAreaElement",audio:"HTMLAudioElement",br:"HTMLBRElement",base:"HTMLBaseElement",body:"HTMLBodyElement",button:"HTMLButtonElement",canvas:"HTMLCanvasElement",dl:"HTMLDListElement",datalist:"HTMLDataListElement",dir:"HTMLDirectoryElement",div:"HTMLDivElement",embed:"HTMLEmbedElement",fieldset:"HTMLFieldSetElement",font:"HTMLFontElement",form:"HTMLFormElement",frame:"HTMLFrameElement",frameset:"HTMLFrameSetElement",hr:"HTMLHRElement",head:"HTMLHeadElement",h1:"HTMLHeadingElement",html:"HTMLHtmlElement",iframe:"HTMLIFrameElement",input:"HTMLInputElement",li:"HTMLLIElement",label:"HTMLLabelElement",legend:"HTMLLegendElement",link:"HTMLLinkElement",map:"HTMLMapElement",menu:"HTMLMenuElement",menuitem:"HTMLMenuItemElement",meta:"HTMLMetaElement",meter:"HTMLMeterElement",del:"HTMLModElement",ol:"HTMLOListElement",object:"HTMLObjectElement",optgroup:"HTMLOptGroupElement",option:"HTMLOptionElement",output:"HTMLOutputElement",p:"HTMLParagraphElement",param:"HTMLParamElement",pre:"HTMLPreElement",progress:"HTMLProgressElement",q:"HTMLQuoteElement",script:"HTMLScriptElement",select:"HTMLSelectElement",source:"HTMLSourceElement",span:"HTMLSpanElement",style:"HTMLStyleElement",caption:"HTMLTableCaptionElement",col:"HTMLTableColElement",table:"HTMLTableElement",tr:"HTMLTableRowElement",thead:"HTMLTableSectionElement",tbody:"HTMLTableSectionElement",textarea:"HTMLTextAreaElement",title:"HTMLTitleElement",ul:"HTMLUListElement",video:"HTMLVideoElement"};Object.keys(n).forEach(t),Object.getOwnPropertyNames(e.wrappers).forEach(function(t){window[t]=e.wrappers[t]}),e.knownElements=n}(this.ShadowDOMPolyfill),function(){var e=window.ShadowDOMPolyfill;e.wrap,Object.defineProperties(HTMLElement.prototype,{webkitShadowRoot:{get:function(){return this.shadowRoot}}}),HTMLElement.prototype.webkitCreateShadowRoot=HTMLElement.prototype.createShadowRoot,window.dartExperimentalFixupGetTag=function(t){function n(e){if(e instanceof r)return"NodeList";if(e instanceof i)return"ShadowRoot";if(e instanceof MutationRecord)return"MutationRecord";if(e instanceof MutationObserver)return"MutationObserver";if(o(e)){e=a(e);var n=e.constructor;if(n&&n._ShadowDOMPolyfill$isGeneratedWrapper){var l=n._ShadowDOMPolyfill$cacheTag_;return l||(l=Object.prototype.toString.call(e),l=l.substring(8,l.length-1),n._ShadowDOMPolyfill$cacheTag_=l),l}}return t(e)}var r=e.wrappers.NodeList,i=e.wrappers.ShadowRoot,o=e.isWrapper,a=e.unwrap;return n}}()} \ No newline at end of file +if(!HTMLElement.prototype.createShadowRoot&&!HTMLElement.prototype.webkitCreateShadowRoot||window.__forceShadowDomPolyfill){!function(){Element.prototype.webkitCreateShadowRoot&&(Element.prototype.webkitCreateShadowRoot=function(){return window.ShadowDOMPolyfill.wrapIfNeeded(this).createShadowRoot()})}();var SideTable;"undefined"!=typeof WeakMap&&navigator.userAgent.indexOf("Firefox/")<0?SideTable=WeakMap:function(){var a=Object.defineProperty,b=Object.hasOwnProperty,c=(new Date).getTime()%1e9;SideTable=function(){this.name="__st"+(1e9*Math.random()>>>0)+(c++ +"__")},SideTable.prototype={set:function(b,c){a(b,this.name,{value:c,writable:!0})},get:function(a){return b.call(a,this.name)?a[this.name]:void 0},"delete":function(a){this.set(a,void 0)}}}();var ShadowDOMPolyfill={};!function(a){"use strict";function b(a){if(!a)throw new Error("Assertion failed")}function c(a,b){return Object.getOwnPropertyNames(b).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))}),a}function d(a,b){return Object.getOwnPropertyNames(b).forEach(function(c){switch(c){case"arguments":case"caller":case"length":case"name":case"prototype":case"toString":return}Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))}),a}function e(a){var b=a.__proto__||Object.getPrototypeOf(a),c=y.get(b);if(c)return c;var d=e(b),f=m(d);return j(b,f,a),f}function f(a,b){h(a,b,!0)}function g(a,b){h(b,a,!1)}function h(a,b,c){Object.getOwnPropertyNames(a).forEach(function(d){if(!(d in b)){A&&a.__lookupGetter__(d);var e;try{e=Object.getOwnPropertyDescriptor(a,d)}catch(f){e=B}var g,h;if(c&&"function"==typeof e.value)return b[d]=function(){return this.impl[d].apply(this.impl,arguments)},void 0;g=function(){return this.impl[d]},(e.writable||e.set)&&(h=function(a){this.impl[d]=a}),Object.defineProperty(b,d,{get:g,set:h,configurable:e.configurable,enumerable:e.enumerable})}})}function i(a,b,c){var e=a.prototype;j(e,b,c),d(b,a)}function j(a,c,d){var e=c.prototype;b(void 0===y.get(a)),y.set(a,c),f(a,e),d&&g(e,d)}function k(a,b){return y.get(b.prototype)===a}function l(a){var b=Object.getPrototypeOf(a),c=e(b),d=m(c);return j(b,d,a),d}function m(a){function b(b){a.call(this,b)}return b.prototype=Object.create(a.prototype),b.prototype.constructor=b,b._ShadowDOMPolyfill$isGeneratedWrapper=!0,b}function n(a){return a instanceof z.EventTarget||a instanceof z.Event||a instanceof z.DOMImplementation}function o(a){return a instanceof E||a instanceof D||a instanceof F||a instanceof C}function p(a){if(null===a)return null;b(o(a));var c=x.get(a);if(!c){var d=e(a);c=new d(a),x.set(a,c)}return c}function q(a){return null===a?null:(b(n(a)),a.impl)}function r(a){return a&&n(a)?q(a):a}function s(a){return a&&!n(a)?p(a):a}function t(a,c){null!==c&&(b(o(a)),b(void 0===c||n(c)),x.set(a,c))}function u(a,b,c){Object.defineProperty(a.prototype,b,{get:c,configurable:!0,enumerable:!0})}function v(a,b){u(a,b,function(){return p(this.impl[b])})}function w(a,b){a.forEach(function(a){b.forEach(function(b){a.prototype[b]=function(){var a=p(this);return a[b].apply(a,arguments)}})})}var x=new SideTable,y=new SideTable,z=Object.create(null);Object.getOwnPropertyNames(window);var A=/Firefox/.test(navigator.userAgent),B={get:function(){},set:function(){},configurable:!0,enumerable:!0},C=DOMImplementation,D=Event,E=Node,F=Window;a.assert=b,a.defineGetter=u,a.defineWrapGetter=v,a.forwardMethodsToWrapper=w,a.isWrapper=n,a.isWrapperFor=k,a.mixin=c,a.registerObject=l,a.registerWrapper=i,a.rewrap=t,a.unwrap=q,a.unwrapIfNeeded=r,a.wrap=p,a.wrapIfNeeded=s,a.wrappers=z}(this.ShadowDOMPolyfill),function(a){"use strict";function b(a){return a instanceof J.ShadowRoot}function c(a){var b=a.localName;return"content"===b||"shadow"===b}function d(a){return!!a.shadowRoot}function e(a){var b;return a.parentNode||(b=a.defaultView)&&I(b)||null}function f(f,g,h){if(h.length)return h.shift();if(b(f))return f.insertionParent||a.getHostForShadowRoot(f);var i=a.eventParentsTable.get(f);if(i){for(var j=1;j=0;b--)if(!c(a[b]))return a[b];return null}function i(d,e){for(var g=[];d;){for(var i=[],k=e,m=void 0;k;){var n=null;if(i.length){if(c(k)&&(n=h(i),j(m))){var o=i[i.length-1];i.push(o)}}else i.push(k);if(l(k,d))return i[i.length-1];b(k)&&i.pop(),m=k,k=f(k,n,g)}d=b(d)?a.getHostForShadowRoot(d):d.parentNode}}function j(a){return a.insertionParent}function k(a){for(var b;b=a.parentNode;)a=b;return a}function l(a,b){return k(a)===k(b)}function m(a){switch(a){case"DOMAttrModified":case"DOMAttributeNameChanged":case"DOMCharacterDataModified":case"DOMElementNameChanged":case"DOMNodeInserted":case"DOMNodeInsertedIntoDocument":case"DOMNodeRemoved":case"DOMNodeRemovedFromDocument":case"DOMSubtreeModified":return!0}return!1}function n(b){if(!L.get(b)){L.set(b,!0),m(b.type)||a.renderAllPending();var c=I(b.target),d=I(b);return o(d,c)}}function o(a,b){var c=g(b);return"load"===a.type&&2===c.length&&c[0].target instanceof J.Document&&c.shift(),p(a,c)&&q(a,c)&&r(a,c),P.set(a,u.NONE),N.set(a,null),a.defaultPrevented}function p(a,b){for(var c,d=b.length-1;d>0;d--){var e=b[d].target,f=b[d].currentTarget;if(e!==f&&(c=u.CAPTURING_PHASE,!s(b[d],a,c)))return!1}return!0}function q(a,b){var c=u.AT_TARGET;return s(b[0],a,c)}function r(a,b){for(var c,d=a.bubbles,e=1;ed;d++)b[d]=f(a[d]);return b.length=e,b}function e(a,b){a.prototype[b]=function(){return d(this.impl[b].apply(this.impl,arguments))}}var f=a.wrap;c.prototype={item:function(a){return this[a]}},b(c.prototype,"item"),a.wrappers.NodeList=c,a.addWrapNodeListMethod=e,a.wrapNodeList=d}(this.ShadowDOMPolyfill),function(a){"use strict";function b(a){i(a instanceof f)}function c(a,b,c,d){if(a.nodeType!==f.DOCUMENT_FRAGMENT_NODE)return a.parentNode&&a.parentNode.removeChild(a),a.parentNode_=b,a.previousSibling_=c,a.nextSibling_=d,c&&(c.nextSibling_=a),d&&(d.previousSibling_=a),[a];for(var e,g=[];e=a.firstChild;)a.removeChild(e),g.push(e),e.parentNode_=b;for(var h=0;h";case Node.TEXT_NODE:return c(a.nodeValue);case Node.COMMENT_NODE:return"";default:throw console.error(a),new Error("not implemented")}}function e(a){for(var b="",c=a.firstChild;c;c=c.nextSibling)b+=d(c);return b}function f(a,b,c){var d=c||"div";a.textContent="";var e=n(a.ownerDocument.createElement(d));e.innerHTML=b;for(var f;f=e.firstChild;)a.appendChild(o(f))}function g(a){j.call(this,a)}function h(b){k(g,b,function(){return a.renderAllPending(),this.impl[b]})}function i(b){Object.defineProperty(g.prototype,b,{value:function(){return a.renderAllPending(),this.impl[b].apply(this.impl,arguments)},configurable:!0,enumerable:!0})}var j=a.wrappers.Element,k=a.defineGetter,l=a.mixin,m=a.registerWrapper,n=a.unwrap,o=a.wrap,p=/&|<|"/g,q={area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},r=window.HTMLElement;g.prototype=Object.create(j.prototype),l(g.prototype,{get innerHTML(){return e(this)},set innerHTML(a){f(this,a,this.tagName)},get outerHTML(){return d(this)},set outerHTML(a){if(this.invalidateShadowRenderer())throw new Error("not implemented");this.impl.outerHTML=a}}),["clientHeight","clientLeft","clientTop","clientWidth","offsetHeight","offsetLeft","offsetTop","offsetWidth","scrollHeight","scrollLeft","scrollTop","scrollWidth"].forEach(h),["getBoundingClientRect","getClientRects","scrollIntoView"].forEach(i),m(r,g,document.createElement("b")),a.wrappers.HTMLElement=g,a.getInnerHTML=e,a.setInnerHTML=f}(this.ShadowDOMPolyfill),function(a){"use strict";function b(a){c.call(this,a)}var c=a.wrappers.HTMLElement,d=a.mixin,e=a.registerWrapper,f=window.HTMLContentElement;b.prototype=Object.create(c.prototype),d(b.prototype,{get select(){return this.getAttribute("select")},set select(a){this.setAttribute("select",a)},setAttribute:function(a,b){c.prototype.setAttribute.call(this,a,b),"select"===String(a).toLowerCase()&&this.invalidateShadowRenderer(!0)}}),f&&e(f,b),a.wrappers.HTMLContentElement=b}(this.ShadowDOMPolyfill),function(a){"use strict";function b(a){c.call(this,a),this.olderShadowRoot_=null}var c=a.wrappers.HTMLElement,d=a.mixin,e=a.registerWrapper,f=window.HTMLShadowElement;b.prototype=Object.create(c.prototype),d(b.prototype,{get olderShadowRoot(){return this.olderShadowRoot_},invalidateShadowRenderer:function(){c.prototype.invalidateShadowRenderer.call(this,!0)}}),f&&e(f,b),a.wrappers.HTMLShadowElement=b}(this.ShadowDOMPolyfill),function(a){"use strict";function b(a){if(!a.defaultView)return a;var b=l.get(a);if(!b){for(b=a.implementation.createHTMLDocument("");b.lastChild;)b.removeChild(b.lastChild);l.set(a,b)}return b}function c(a){for(var c,d=b(a.ownerDocument),e=d.createDocumentFragment();c=a.firstChild;)e.appendChild(c);return e}function d(a){e.call(this,a)}var e=a.wrappers.HTMLElement,f=a.getInnerHTML,g=a.mixin,h=a.registerWrapper,i=a.setInnerHTML,j=a.wrap,k=new SideTable,l=new SideTable,m=window.HTMLTemplateElement;d.prototype=Object.create(e.prototype),g(d.prototype,{get content(){if(m)return j(this.impl.content);var a=k.get(this);return a||(a=c(this),k.set(this,a)),a},get innerHTML(){return f(this.content)},set innerHTML(a){i(this.content,a),this.invalidateShadowRenderer()}}),m&&h(m,d),a.wrappers.HTMLTemplateElement=d}(this.ShadowDOMPolyfill),function(a){"use strict";function b(a){switch(a.localName){case"content":return new c(a);case"shadow":return new e(a);case"template":return new f(a)}d.call(this,a)}var c=a.wrappers.HTMLContentElement,d=a.wrappers.HTMLElement,e=a.wrappers.HTMLShadowElement,f=a.wrappers.HTMLTemplateElement;a.mixin;var g=a.registerWrapper,h=window.HTMLUnknownElement;b.prototype=Object.create(d.prototype),g(h,b),a.wrappers.HTMLUnknownElement=b}(this.ShadowDOMPolyfill),function(a){"use strict";var b=a.GetElementsByInterface,c=a.ParentNodeInterface,d=a.SelectorsInterface,e=a.mixin,f=a.registerObject,g=f(document.createDocumentFragment());e(g.prototype,c),e(g.prototype,d),e(g.prototype,b);var h=f(document.createTextNode("")),i=f(document.createComment(""));a.wrappers.Comment=i,a.wrappers.DocumentFragment=g,a.wrappers.Text=h}(this.ShadowDOMPolyfill),function(a){"use strict";function b(b){var d=i(b.impl.ownerDocument.createDocumentFragment());c.call(this,d),g(d,this);var e=b.shadowRoot;a.nextOlderShadowTreeTable.set(this,e),j.set(this,b)}var c=a.wrappers.DocumentFragment,d=a.elementFromPoint,e=a.getInnerHTML,f=a.mixin,g=a.rewrap,h=a.setInnerHTML,i=a.unwrap,j=new SideTable;b.prototype=Object.create(c.prototype),f(b.prototype,{get innerHTML(){return e(this)},set innerHTML(a){h(this,a),this.invalidateShadowRenderer()},invalidateShadowRenderer:function(){return j.get(this).invalidateShadowRenderer()},elementFromPoint:function(a,b){return d(this,this.ownerDocument,a,b)},getElementById:function(a){return this.querySelector("#"+a)}}),a.wrappers.ShadowRoot=b,a.getHostForShadowRoot=function(a){return j.get(a)}}(this.ShadowDOMPolyfill),function(a){"use strict";function b(a){a.previousSibling_=a.previousSibling,a.nextSibling_=a.nextSibling,a.parentNode_=a.parentNode}function c(a){a.firstChild_=a.firstChild,a.lastChild_=a.lastChild}function d(a){F(a instanceof E);for(var d=a.firstChild;d;d=d.nextSibling)b(d);c(a)}function e(a){var b=H(a);d(a),b.textContent=""}function f(a,c){var e=H(a),f=H(c);f.nodeType===E.DOCUMENT_FRAGMENT_NODE?d(c):(h(c),b(c)),a.lastChild_=a.lastChild,a.lastChild===a.firstChild&&(a.firstChild_=a.firstChild);var g=I(e.lastChild);g&&(g.nextSibling_=g.nextSibling),e.appendChild(f)}function g(a,c){var d=H(a),e=H(c);b(c),c.previousSibling&&(c.previousSibling.nextSibling_=c),c.nextSibling&&(c.nextSibling.previousSibling_=c),a.lastChild===c&&(a.lastChild_=c),a.firstChild===c&&(a.firstChild_=c),d.removeChild(e)}function h(a){var b=H(a),c=b.parentNode;c&&g(I(c),a)}function i(a,b){k(b).push(a),L.set(a,b);var c=K.get(a);c||K.set(a,c=[]),c.push(b)}function j(a){J.set(a,[])}function k(a){return J.get(a)}function l(a){for(var b=[],c=0,d=a.firstChild;d;d=d.nextSibling)b[c++]=d;return b}function m(a,b,c){for(var d=l(a),e=0;e","+","~"],d=a,e="["+b+"]";return c.forEach(function(a){var b=d.split(a);d=b.map(function(a){var b=a.trim();return b&&c.indexOf(b)<0&&b.indexOf(e)<0&&(a=b.replace(/([^:]*)(:*)(.*)/,"$1"+e+"$2$3")),a}).join(a)}),d},propertiesFromRule:function(a){var b=a.style.cssText;return a.style.content&&!a.style.content.match(/['"]+/)&&(b="content: '"+a.style.content+"';\n"+a.style.cssText.replace(/content:[^;]*;/g,"")),b}},i=/@host[^{]*{(([^}]*?{[^{]*?}[\s\S]*?)+)}/gim,j=/([^{]*)({[\s\S]*?})/gim,k=/(.*)((?:\*)|(?:\:scope))(.*)/,l=/^[.\[:]/,m=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim,n=/\/\*\s*@polyfill ([^*]*\*+([^/*][^*]*\*+)*\/)([^{]*?){/gim,o=/::(x-[^\s{,(]*)/gim,p="([>\\s~+[.,{:][\\s\\S]*)?$",q=/@host/gim;if(window.ShadowDOMPolyfill){e("style { display: none !important; }\n");var r=document.querySelector("head");r.insertBefore(f(),r.childNodes[0])}a.ShadowCSS=h}(window.Platform),function(a){function b(a,b){if(window.ShadowDOMPolyfill){for(var h,i=this.convertPolyfillDirectives(a,b),j="",k=0;h=e.exec(i);)j+=i.substring(k,h.index),j+=this.scopeHostCss(h[1],b),k=e.lastIndex;j+=i.substring(k,i.length);var l=new RegExp("^"+b+g,"m"),m=d(this.findAtHostRules(c(j),l));i=i.replace(f,""),i=this.convertPseudos(i);var n=c(i),o=this.scopeRules(n,b);return m+o}}function c(a){var b=document.createElement("style");b.textContent=a,document.head.appendChild(b);var c=b.sheet.cssRules;return b.parentNode.removeChild(b),c}function d(a){for(var b=0,c=[];b\\s~+[.,{:][\\s\\S]*)?$";a.ShadowCSS.shimShadowDOMStyling2=b}(window.Platform)} \ No newline at end of file diff --git a/pkg/shadow_dom/lib/src/platform/ShadowCSS.js b/pkg/shadow_dom/lib/src/platform/ShadowCSS.js new file mode 100644 index 00000000000..96861a13640 --- /dev/null +++ b/pkg/shadow_dom/lib/src/platform/ShadowCSS.js @@ -0,0 +1,452 @@ +/* + * Copyright 2012 The Polymer Authors. All rights reserved. + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file. + */ + +/* + This is a limited shim for ShadowDOM css styling. + https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#styles + + The intention here is to support only the styling features which can be + relatively simply implemented. The goal is to allow users to avoid the + most obvious pitfalls and do so without compromising performance significantly. + For ShadowDOM styling that's not covered here, a set of best practices + can be provided that should allow users to accomplish more complex styling. + + The following is a list of specific ShadowDOM styling features and a brief + discussion of the approach used to shim. + + Shimmed features: + + * @host: ShadowDOM allows styling of the shadowRoot's host element using the + @host rule. To shim this feature, the @host styles are reformatted and + prefixed with a given scope name and promoted to a document level stylesheet. + For example, given a scope name of .foo, a rule like this: + + @host { + * { + background: red; + } + } + + becomes: + + .foo { + background: red; + } + + * encapsultion: Styles defined within ShadowDOM, apply only to + dom inside the ShadowDOM. Polymer uses one of two techniques to imlement + this feature. + + By default, rules are prefixed with the host element tag name + as a descendant selector. This ensures styling does not leak out of the 'top' + of the element's ShadowDOM. For example, + + div { + font-weight: bold; + } + + becomes: + + x-foo div { + font-weight: bold; + } + + becomes: + + + Alternatively, if Platform.ShadowCSS.strictStyling is set to true then + selectors are scoped by adding an attribute selector suffix to each + simple selector that contains the host element tag name. Each element + in the element's ShadowDOM template is also given the scope attribute. + Thus, these rules match only elements that have the scope attribute. + For example, given a scope name of x-foo, a rule like this: + + div { + font-weight: bold; + } + + becomes: + + div[x-foo] { + font-weight: bold; + } + + Note that elements that are dynamically added to a scope must have the scope + selector added to them manually. + + * ::pseudo: These rules are converted to rules that take advantage of the + pseudo attribute. For example, a shadowRoot like this inside an x-foo + +
Special
+ + with a rule like this: + + x-foo::x-special { ... } + + becomes: + + x-foo [pseudo=x-special] { ... } + + Unaddressed ShadowDOM styling features: + + * upper/lower bound encapsulation: Styles which are defined outside a + shadowRoot should not cross the ShadowDOM boundary and should not apply + inside a shadowRoot. + + This styling behavior is not emulated. Some possible ways to do this that + were rejected due to complexity and/or performance concerns include: (1) reset + every possible property for every possible selector for a given scope name; + (2) re-implement css in javascript. + + As an alternative, users should make sure to use selectors + specific to the scope in which they are working. + + * ::distributed: This behavior is not emulated. It's often not necessary + to style the contents of a specific insertion point and instead, descendants + of the host element can be styled selectively. Users can also create an + extra node around an insertion point and style that node's contents + via descendent selectors. For example, with a shadowRoot like this: + + + + + could become: + + +
+ +
+ + Note the use of @polyfill in the comment above a ShadowDOM specific style + declaration. This is a directive to the styling shim to use the selector + in comments in lieu of the next selector when running under polyfill. +*/ +(function(scope) { + +var ShadowCSS = { + strictStyling: false, + registry: {}, + // Shim styles for a given root associated with a name and extendsName + // 1. cache root styles by name + // 2. optionally tag root nodes with scope name + // 3. shim polyfill directives /* @polyfill */ + // 4. shim @host and scoping + shimStyling: function(root, name, extendsName) { + if (root) { + // use caching to make working with styles nodes easier and to facilitate + // lookup of extendee + var def = this.registerDefinition(root, name, extendsName); + // find styles and apply shimming... + if (this.strictStyling) { + this.applyScopeToContent(root, name); + } + this.shimPolyfillDirectives(def.rootStyles, name); + this.applyShimming(def.scopeStyles, name); + } + }, + // Shim styles to be placed inside a shadowRoot. + // 1. shim polyfill directives /* @polyfill */ + // 2. shim @host and scoping + shimShadowDOMStyling: function(styles, name) { + this.shimPolyfillDirectives(styles, name); + this.applyShimming(styles, name); + }, + registerDefinition: function(root, name, extendsName) { + var def = this.registry[name] = { + root: root, + name: name, + extendsName: extendsName + } + var styles = root.querySelectorAll('style'); + styles = styles ? Array.prototype.slice.call(styles, 0) : []; + def.rootStyles = styles; + def.scopeStyles = def.rootStyles; + var extendee = this.registry[def.extendsName]; + if (extendee) { + def.scopeStyles = def.scopeStyles.concat(extendee.scopeStyles); + } + return def; + }, + applyScopeToContent: function(root, name) { + if (root) { + // add the name attribute to each node in root. + Array.prototype.forEach.call(root.querySelectorAll('*'), + function(node) { + node.setAttribute(name, ''); + }); + // and template contents too + Array.prototype.forEach.call(root.querySelectorAll('template'), + function(template) { + this.applyScopeToContent(template.content, name); + }, + this); + } + }, + /* + * Process styles to convert native ShadowDOM rules that will trip + * up the css parser; we rely on decorating the stylesheet with comments. + * + * For example, we convert this rule: + * + * (comment start) @polyfill @host g-menu-item (comment end) + * shadow::-webkit-distributed(g-menu-item) { + * + * to this: + * + * scopeName g-menu-item { + * + **/ + shimPolyfillDirectives: function(styles, name) { + if (styles) { + Array.prototype.forEach.call(styles, function(s) { + s.textContent = this.convertPolyfillDirectives(s.textContent, name); + }, this); + } + }, + convertPolyfillDirectives: function(cssText, name) { + var r = '', l = 0, matches, selector; + while (matches = cssPolyfillCommentRe.exec(cssText)) { + r += cssText.substring(l, matches.index); + // remove end comment delimiter (*/) + selector = matches[1].slice(0, -2).replace(hostRe, name); + r += this.scopeSelector(selector, name) + '{'; + l = cssPolyfillCommentRe.lastIndex; + } + r += cssText.substring(l, cssText.length); + return r; + }, + // apply @host and scope shimming + applyShimming: function(styles, name) { + var cssText = this.shimAtHost(styles, name); + cssText += this.shimScoping(styles, name); + addCssToDocument(cssText); + }, + // form: @host { .foo { declarations } } + // becomes: scopeName.foo { declarations } + shimAtHost: function(styles, name) { + if (styles) { + return this.convertAtHostStyles(styles, name); + } + }, + convertAtHostStyles: function(styles, name) { + var cssText = stylesToCssText(styles); + var r = '', l=0, matches; + while (matches = hostRuleRe.exec(cssText)) { + r += cssText.substring(l, matches.index); + r += this.scopeHostCss(matches[1], name); + l = hostRuleRe.lastIndex; + } + r += cssText.substring(l, cssText.length); + var re = new RegExp('^' + name + selectorReSuffix, 'm'); + var cssText = rulesToCss(this.findAtHostRules(cssToRules(r), + re)); + return cssText; + }, + scopeHostCss: function(cssText, name) { + var r = '', matches; + while (matches = selectorRe.exec(cssText)) { + r += this.scopeHostSelector(matches[1], name) +' ' + matches[2] + '\n\t'; + } + return r; + }, + // supports scopig by name and [is=name] syntax + scopeHostSelector: function(selector, name) { + var r = [], parts = selector.split(','), is = '[is=' + name + ']'; + parts.forEach(function(p) { + p = p.trim(); + // selector: *|:scope -> name + if (p.match(hostElementRe)) { + p = p.replace(hostElementRe, name + '$1$3, ' + is + '$1$3'); + // selector: .foo -> name.foo, [bar] -> name[bar] + } else if (p.match(hostFixableRe)) { + p = name + p + ', ' + is + p; + } + r.push(p); + }, this); + return r.join(', '); + }, + // consider styles that do not include component name in the selector to be + // unscoped and in need of promotion; + // for convenience, also consider keyframe rules this way. + findAtHostRules: function(cssRules, matcher) { + return Array.prototype.filter.call(cssRules, + this.isHostRule.bind(this, matcher)); + }, + isHostRule: function(matcher, cssRule) { + return (cssRule.selectorText && cssRule.selectorText.match(matcher)) || + (cssRule.cssRules && this.findAtHostRules(cssRule.cssRules, matcher).length) || + (cssRule.type == CSSRule.WEBKIT_KEYFRAMES_RULE); + }, + /* Ensure styles are scoped. Pseudo-scoping takes a rule like: + * + * .foo {... } + * + * and converts this to + * + * scopeName .foo { ... } + */ + shimScoping: function(styles, name) { + if (styles) { + return this.convertScopedStyles(styles, name); + } + }, + convertScopedStyles: function(styles, name) { + Array.prototype.forEach.call(styles, function(s) { + if (s.parentNode) { + s.parentNode.removeChild(s); + } + }); + var cssText = stylesToCssText(styles).replace(hostRuleRe, ''); + cssText = this.convertPseudos(cssText); + var rules = cssToRules(cssText); + cssText = this.scopeRules(rules, name); + return cssText; + }, + convertPseudos: function(cssText) { + return cssText.replace(cssPseudoRe, ' [pseudo=$1]'); + }, + // change a selector like 'div' to 'name div' + scopeRules: function(cssRules, name) { + var cssText = ''; + Array.prototype.forEach.call(cssRules, function(rule) { + if (rule.selectorText && (rule.style && rule.style.cssText)) { + cssText += this.scopeSelector(rule.selectorText, name, + this.strictStyling) + ' {\n\t'; + cssText += this.propertiesFromRule(rule) + '\n}\n\n'; + } else if (rule.media) { + cssText += '@media ' + rule.media.mediaText + ' {\n'; + cssText += this.scopeRules(rule.cssRules, name); + cssText += '\n}\n\n'; + } else if (rule.cssText) { + cssText += rule.cssText + '\n\n'; + } + }, this); + return cssText; + }, + scopeSelector: function(selector, name, strict) { + var r = [], parts = selector.split(','); + parts.forEach(function(p) { + p = p.trim(); + if (this.selectorNeedsScoping(p, name)) { + p = strict ? this.applyStrictSelectorScope(p, name) : + this.applySimpleSelectorScope(p, name); + } + r.push(p); + }, this); + return r.join(', '); + }, + selectorNeedsScoping: function(selector, name) { + var matchScope = '(' + name + '|\\[is=' + name + '\\])'; + var re = new RegExp('^' + matchScope + selectorReSuffix, 'm'); + return !selector.match(re); + }, + // scope via name and [is=name] + applySimpleSelectorScope: function(selector, name) { + return name + ' ' + selector + ', ' + '[is=' + name + '] ' + selector; + }, + // return a selector with [name] suffix on each simple selector + // e.g. .foo.bar > .zot becomes .foo[name].bar[name] > .zot[name] + applyStrictSelectorScope: function(selector, name) { + var splits = [' ', '>', '+', '~'], + scoped = selector, + attrName = '[' + name + ']'; + splits.forEach(function(sep) { + var parts = scoped.split(sep); + scoped = parts.map(function(p) { + var t = p.trim(); + if (t && (splits.indexOf(t) < 0) && (t.indexOf(attrName) < 0)) { + p = t.replace(/([^:]*)(:*)(.*)/, '$1' + attrName + '$2$3') + } + return p; + }).join(sep); + }); + return scoped; + }, + propertiesFromRule: function(rule) { + var properties = rule.style.cssText; + // TODO(sorvell): Chrome cssom incorrectly removes quotes from the content + // property. (https://code.google.com/p/chromium/issues/detail?id=247231) + if (rule.style.content && !rule.style.content.match(/['"]+/)) { + properties = 'content: \'' + rule.style.content + '\';\n' + + rule.style.cssText.replace(/content:[^;]*;/g, ''); + } + return properties; + } +}; + +var hostRuleRe = /@host[^{]*{(([^}]*?{[^{]*?}[\s\S]*?)+)}/gim, + selectorRe = /([^{]*)({[\s\S]*?})/gim, + hostElementRe = /(.*)((?:\*)|(?:\:scope))(.*)/, + hostFixableRe = /^[.\[:]/, + cssCommentRe = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim, + cssPolyfillCommentRe = /\/\*\s*@polyfill ([^*]*\*+([^/*][^*]*\*+)*\/)([^{]*?){/gim, + cssPseudoRe = /::(x-[^\s{,(]*)/gim, + selectorReSuffix = '([>\\s~+\[.,{:][\\s\\S]*)?$', + hostRe = /@host/gim; + +function stylesToCssText(styles, preserveComments) { + var cssText = ''; + Array.prototype.forEach.call(styles, function(s) { + cssText += s.textContent + '\n\n'; + }); + // strip comments for easier processing + if (!preserveComments) { + cssText = cssText.replace(cssCommentRe, ''); + } + return cssText; +} + +function cssToRules(cssText) { + var style = document.createElement('style'); + style.textContent = cssText; + document.head.appendChild(style); + var rules = style.sheet.cssRules; + style.parentNode.removeChild(style); + return rules; +} + +function rulesToCss(cssRules) { + for (var i=0, css=[]; i < cssRules.length; i++) { + css.push(cssRules[i].cssText); + } + return css.join('\n\n'); +} + +function addCssToDocument(cssText) { + if (cssText) { + getSheet().appendChild(document.createTextNode(cssText)); + } +} + +var sheet; +function getSheet() { + if (!sheet) { + sheet = document.createElement("style"); + sheet.setAttribute('ShadowCSSShim', ''); + } + return sheet; +} + +// add polyfill stylesheet to document +if (window.ShadowDOMPolyfill) { + addCssToDocument('style { display: none !important; }\n'); + var head = document.querySelector('head'); + head.insertBefore(getSheet(), head.childNodes[0]); +} + +// exports +scope.ShadowCSS = ShadowCSS; + +})(window.Platform); \ No newline at end of file diff --git a/pkg/shadow_dom/lib/src/platform/patches-shadow-css.js b/pkg/shadow_dom/lib/src/platform/patches-shadow-css.js new file mode 100644 index 00000000000..952557070a4 --- /dev/null +++ b/pkg/shadow_dom/lib/src/platform/patches-shadow-css.js @@ -0,0 +1,65 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +(function(scope) { + // TODO(terry): Remove shimShadowDOMStyling2 until wrap/unwrap from a + // dart:html Element to a JS DOM node is available. + /** + * Given the content of a STYLE tag and the name of a component shim the CSS + * and return the new scoped CSS to replace the STYLE's content. The content + * is replaced in Dart's implementation of PolymerElement. + */ + function shimShadowDOMStyling2(styleContent, name) { + if (window.ShadowDOMPolyfill) { + var content = this.convertPolyfillDirectives(styleContent, name); + + // applyShimming calls shimAtHost and shipScoping + // shimAtHost code: + var r = '', l=0, matches; + while (matches = hostRuleRe.exec(content)) { + r += content.substring(l, matches.index); + r += this.scopeHostCss(matches[1], name); + l = hostRuleRe.lastIndex; + } + r += content.substring(l, content.length); + var re = new RegExp('^' + name + selectorReSuffix, 'm'); + var atHostCssText = rulesToCss(this.findAtHostRules(cssToRules(r), re)); + + // shimScoping code: + // strip comments for easier processing + content = content.replace(cssCommentRe, ''); + + content = this.convertPseudos(content); + var rules = cssToRules(content); + var cssText = this.scopeRules(rules, name); + + return atHostCssText + cssText; + } + } + + // Minimal copied code from ShadowCSS, that is not exposed in + // PlatForm.ShadowCSS (local code). + var hostRuleRe = /@host[^{]*{(([^}]*?{[^{]*?}[\s\S]*?)+)}/gim, + cssCommentRe = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim, + selectorReSuffix = '([>\\s~+\[.,{:][\\s\\S]*)?$'; + + function cssToRules(cssText) { + var style = document.createElement('style'); + style.textContent = cssText; + document.head.appendChild(style); + var rules = style.sheet.cssRules; + style.parentNode.removeChild(style); + return rules; + } + + function rulesToCss(cssRules) { + for (var i=0, css=[]; i < cssRules.length; i++) { + css.push(cssRules[i].cssText); + } + return css.join('\n\n'); + } + + // exports + scope.ShadowCSS.shimShadowDOMStyling2 = shimShadowDOMStyling2; +})(window.Platform); diff --git a/pkg/shadow_dom/lib/src/platform/patches-shadowdom-polyfill-before.js b/pkg/shadow_dom/lib/src/platform/patches-shadowdom-polyfill-before.js new file mode 100644 index 00000000000..fe15015bdc9 --- /dev/null +++ b/pkg/shadow_dom/lib/src/platform/patches-shadowdom-polyfill-before.js @@ -0,0 +1,13 @@ +/* + * Copyright 2013 The Polymer Authors. All rights reserved. + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file. + */ +(function() { + // TODO(jmesserly): fix dart:html to use unprefixed name + if (Element.prototype.webkitCreateShadowRoot) { + Element.prototype.webkitCreateShadowRoot = function() { + return window.ShadowDOMPolyfill.wrapIfNeeded(this).createShadowRoot(); + }; + } +})(); diff --git a/pkg/shadow_dom/lib/src/platform/patches-shadowdom-polyfill.js b/pkg/shadow_dom/lib/src/platform/patches-shadowdom-polyfill.js new file mode 100644 index 00000000000..cafb59787c8 --- /dev/null +++ b/pkg/shadow_dom/lib/src/platform/patches-shadowdom-polyfill.js @@ -0,0 +1,59 @@ +/* + * Copyright 2013 The Polymer Authors. All rights reserved. + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file. + */ +(function() { + var ShadowDOMPolyfill = window.ShadowDOMPolyfill; + var wrap = ShadowDOMPolyfill.wrap; + + // patch in prefixed name + Object.defineProperties(HTMLElement.prototype, { + //TODO(sjmiles): review accessor alias with Arv + webkitShadowRoot: { + get: function() { + return this.shadowRoot; + } + } + }); + + //TODO(sjmiles): review method alias with Arv + HTMLElement.prototype.webkitCreateShadowRoot = + HTMLElement.prototype.createShadowRoot; + + // TODO(jmesserly): we need to wrap document somehow (a dart:html hook?) + window.dartExperimentalFixupGetTag = function(originalGetTag) { + var NodeList = ShadowDOMPolyfill.wrappers.NodeList; + var ShadowRoot = ShadowDOMPolyfill.wrappers.ShadowRoot; + var isWrapper = ShadowDOMPolyfill.isWrapper; + var unwrap = ShadowDOMPolyfill.unwrap; + function getTag(obj) { + if (obj instanceof NodeList) return 'NodeList'; + if (obj instanceof ShadowRoot) return 'ShadowRoot'; + if (obj instanceof MutationRecord) return 'MutationRecord'; + if (obj instanceof MutationObserver) return 'MutationObserver'; + + if (isWrapper(obj)) { + obj = unwrap(obj); + + // Fix up class names for Firefox. For some of them like + // HTMLFormElement and HTMLInputElement, the "constructor" property of + // the unwrapped nodes points at the wrapper for some reason. + // TODO(jmesserly): figure out why this is happening. + var ctor = obj.constructor; + if (ctor && ctor._ShadowDOMPolyfill$isGeneratedWrapper) { + var name = ctor._ShadowDOMPolyfill$cacheTag_; + if (!name) { + name = Object.prototype.toString.call(obj); + name = name.substring(8, name.length - 1); + ctor._ShadowDOMPolyfill$cacheTag_ = name; + } + return name; + } + } + return originalGetTag(obj); + } + + return getTag; + }; +})(); diff --git a/pkg/shadow_dom/lib/src/platform/platform-init.js b/pkg/shadow_dom/lib/src/platform/platform-init.js new file mode 100644 index 00000000000..4e83afc8c5f --- /dev/null +++ b/pkg/shadow_dom/lib/src/platform/platform-init.js @@ -0,0 +1,5 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +var Platform = {}; diff --git a/pkg/shadow_dom/test/runner.html b/pkg/shadow_dom/test/runner.html new file mode 100644 index 00000000000..83dd0eeaced --- /dev/null +++ b/pkg/shadow_dom/test/runner.html @@ -0,0 +1,17 @@ + + + + + + + + + +
+ diff --git a/pkg/shadow_dom/test/runner.min.html b/pkg/shadow_dom/test/runner.min.html new file mode 100644 index 00000000000..6c45525be99 --- /dev/null +++ b/pkg/shadow_dom/test/runner.min.html @@ -0,0 +1,18 @@ + + + + + + + + + +
+ + diff --git a/pkg/shadow_dom/tool/build/else.js b/pkg/shadow_dom/tool/build/else.js new file mode 100644 index 00000000000..dacd7620661 --- /dev/null +++ b/pkg/shadow_dom/tool/build/else.js @@ -0,0 +1 @@ +} else { \ No newline at end of file diff --git a/pkg/shadow_dom/tool/build/end-if.js b/pkg/shadow_dom/tool/build/end-if.js new file mode 100644 index 00000000000..ff30235f076 --- /dev/null +++ b/pkg/shadow_dom/tool/build/end-if.js @@ -0,0 +1 @@ +} \ No newline at end of file diff --git a/pkg/shadow_dom/tool/build/if-poly.js b/pkg/shadow_dom/tool/build/if-poly.js new file mode 100644 index 00000000000..7503d653851 --- /dev/null +++ b/pkg/shadow_dom/tool/build/if-poly.js @@ -0,0 +1,3 @@ +if ((!HTMLElement.prototype.createShadowRoot && + !HTMLElement.prototype.webkitCreateShadowRoot) || + window.__forceShadowDomPolyfill) { diff --git a/pkg/shadow_dom/tool/conf/karma.conf.js b/pkg/shadow_dom/tool/conf/karma.conf.js new file mode 100644 index 00000000000..382e2c7796c --- /dev/null +++ b/pkg/shadow_dom/tool/conf/karma.conf.js @@ -0,0 +1,89 @@ +// Sample Karma configuration file, that contain pretty much all the available options +// It's used for running client tests on Travis (http://travis-ci.org/#!/karma-runner/karma) +// Most of the options can be overriden by cli arguments (see karma --help) +// +// For all available config options and default values, see: +// https://github.com/karma-runner/karma/blob/stable/lib/config.js#L54 + + +// base path, that will be used to resolve files and exclude +basePath = '../'; + +// list of files / patterns to load in the browser +files = [ + 'tools/test/mocha-htmltest.js', + 'conf/mocha.conf.js', + 'node_modules/chai/chai.js', + 'shadowdom.js', + 'test/test.main.js', + {pattern: 'src/**/*.js', included: false}, + {pattern: 'test/**/*.js', included: false}, + {pattern: 'test/**/*.html', included: false}, + {pattern: 'tools/**/*.js', included: false} +]; + +// list of files to exclude +exclude = []; + +frameworks = ['mocha']; + +// use dots reporter, as travis terminal does not support escaping sequences +// possible values: 'dots', 'progress', 'junit', 'teamcity' +// CLI --reporters progress +reporters = ['progress']; + +// web server port +// CLI --port 9876 +port = 9876; + +// cli runner port +// CLI --runner-port 9100 +runnerPort = 9100; + +// enable / disable colors in the output (reporters and logs) +// CLI --colors --no-colors +colors = true; + +// level of logging +// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG +// CLI --log-level debug +logLevel = LOG_INFO; + +// enable / disable watching file and executing tests whenever any file changes +// CLI --auto-watch --no-auto-watch +autoWatch = true; + +// Start these browsers, currently available: +// - Chrome +// - ChromeCanary +// - Firefox +// - Opera +// - Safari (only Mac) +// - PhantomJS +// - IE (only Windows) +// CLI --browsers Chrome,Firefox,Safari +browsers = ['ChromeCanary']; + +// If browser does not capture in given timeout [ms], kill it +// CLI --capture-timeout 5000 +captureTimeout = 50000; + +// Auto run tests on start (when browsers are captured) and exit +// CLI --single-run --no-single-run +singleRun = true; + +// report which specs are slower than 500ms +// CLI --report-slower-than 500 +reportSlowerThan = 500; + +// compile coffee scripts +preprocessors = { +}; + +plugins = [ + 'karma-mocha', + 'karma-chrome-launcher', + 'karma-firefox-launcher', + 'karma-script-launcher', + 'karma-crbot-reporter' +] diff --git a/pkg/shadow_dom/tool/conf/mocha.conf.js b/pkg/shadow_dom/tool/conf/mocha.conf.js new file mode 100644 index 00000000000..11dd0d62d01 --- /dev/null +++ b/pkg/shadow_dom/tool/conf/mocha.conf.js @@ -0,0 +1 @@ +mocha.setup({ui:'tdd',htmlbase: '/base/test/'}); diff --git a/pkg/shadow_dom/tool/gruntfile.js b/pkg/shadow_dom/tool/gruntfile.js new file mode 100644 index 00000000000..f245d730352 --- /dev/null +++ b/pkg/shadow_dom/tool/gruntfile.js @@ -0,0 +1,143 @@ +/* + * Copyright 2013 The Polymer Authors. All rights reserved. + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file. + */ +module.exports = function(grunt) { + ShadowDOMPolyfill = [ + 'sidetable.js', + 'wrappers.js', + 'wrappers/events.js', + 'wrappers/NodeList.js', + 'wrappers/Node.js', + 'querySelector.js', + 'wrappers/node-interfaces.js', + 'wrappers/CharacterData.js', + 'wrappers/Element.js', + 'wrappers/HTMLElement.js', + 'wrappers/HTMLContentElement.js', + 'wrappers/HTMLShadowElement.js', + 'wrappers/HTMLTemplateElement.js', + 'wrappers/HTMLUnknownElement.js', + 'wrappers/generic.js', + 'wrappers/ShadowRoot.js', + 'ShadowRenderer.js', + 'wrappers/Document.js', + 'wrappers/Window.js', + 'wrappers/MutationObserver.js', + 'wrappers/override-constructors.js' + ]; + ShadowDOMPolyfill = ShadowDOMPolyfill.map(function(p) { + return '../../../third_party/polymer/ShadowDOM/src/' + p; + }); + + // Apply partial patch from Polymer/Platform, dart2js, CSS + // polyfill from platform and dart2js CSS patches: + ShadowDOMPolyfill.unshift( + '../lib/src/platform/patches-shadowdom-polyfill-before.js' + ); + ShadowDOMPolyfill.push( + '../lib/src/platform/patches-shadowdom-polyfill.js', + '../lib/src/platform/platform-init.js', + '../lib/src/platform/ShadowCSS.js', + '../lib/src/platform/patches-shadow-css.js' + ); + + // Only load polyfill if not natively present. + ConditionalShadowDOM = [].concat( + 'build/if-poly.js', + ShadowDOMPolyfill, + 'build/end-if.js' + ); + + // karma setup + var browsers; + (function() { + try { + var config = grunt.file.readJSON('local.json'); + if (config.browsers) { + browsers = config.browsers; + } + } catch (e) { + var os = require('os'); + browsers = ['Chrome', 'Firefox']; + if (os.type() === 'Darwin') { + browsers.push('ChromeCanary'); + } + if (os.type() === 'Windows_NT') { + browsers.push('IE'); + } + } + })(); + grunt.initConfig({ + karma: { + options: { + configFile: 'conf/karma.conf.js', + keepalive: true, + browsers: browsers + }, + buildbot: { + browsers: browsers, + reporters: ['crbot'], + logLevel: 'OFF' + }, + ShadowDOM: { + browsers: browsers + } + }, + concat: { + ShadowDOM: { + src: ConditionalShadowDOM, + dest: '../lib/shadow_dom.debug.js', + nonull: true + } + }, + uglify: { + ShadowDOM: { + options: { + compress: { + // TODO(sjmiles): should be false by default (?) + // https://github.com/mishoo/UglifyJS2/issues/165 + unsafe: false + } + //compress: true, Xmangle: true, beautify: true, unsafe: false + }, + files: { + '../lib/shadow_dom.min.js': ['../lib/shadow_dom.debug.js'] + } + } + }, + + yuidoc: { + compile: { + name: '<%= pkg.name %>', + description: '<%= pkg.description %>', + version: '<%= pkg.version %>', + url: '<%= pkg.homepage %>', + options: { + exclude: 'third_party', + paths: '.', + outdir: 'docs', + linkNatives: 'true', + tabtospace: 2, + themedir: '../docs/doc_themes/simple' + } + } + }, + pkg: grunt.file.readJSON('package.json') + }); + + // plugins + grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-contrib-yuidoc'); + grunt.loadNpmTasks('grunt-karma-0.9.1'); + + // tasks + grunt.registerTask('default', ['concat', 'uglify']); + grunt.registerTask('minify', ['concat', 'uglify']); + grunt.registerTask('docs', ['yuidoc']); + grunt.registerTask('test', ['karma:ShadowDOM']); + grunt.registerTask('test-buildbot', ['karma:buildbot']); +}; + diff --git a/pkg/shadow_dom/tool/package.json b/pkg/shadow_dom/tool/package.json new file mode 100644 index 00000000000..766ca2812b6 --- /dev/null +++ b/pkg/shadow_dom/tool/package.json @@ -0,0 +1,16 @@ +{ + "name": "ShadowDOM", + "version": "0.0.1", + "devDependencies": { + "mocha": ">=1.9", + "chai": "*", + "grunt": "*", + "grunt-contrib-concat": "*", + "grunt-contrib-uglify": "*", + "grunt-contrib-yuidoc": "~0.4.0", + "grunt-karma-0.9.1": "~0.4.3", + "karma-mocha": "*", + "karma-script-launcher": "*", + "karma-crbot-reporter": "*" + } +} diff --git a/pkg/shadow_dom/tool/play.html b/pkg/shadow_dom/tool/play.html new file mode 100644 index 00000000000..f17b4710d59 --- /dev/null +++ b/pkg/shadow_dom/tool/play.html @@ -0,0 +1,39 @@ + + + + + + + + + +
Real
+ + diff --git a/pkg/shadow_dom/tool/readme.txt b/pkg/shadow_dom/tool/readme.txt new file mode 100644 index 00000000000..829c6978294 --- /dev/null +++ b/pkg/shadow_dom/tool/readme.txt @@ -0,0 +1,18 @@ +How to build shadow_dom package: + +- Install nodejs and npm + sudo apt-get install nodejs + sudo apt-get install npm +- Install grunt http://gruntjs.com/getting-started + +- Change to the shadow_dom tool directory + cd pkg/shadow_dom/tool + +- Install project dependencies + npm install + +- Run grunt to generate the shadow_dom packages in pkg/shadow_dom/lib + grunt + + + diff --git a/pkg/shadow_dom/tool/shadowdom.js b/pkg/shadow_dom/tool/shadowdom.js new file mode 100644 index 00000000000..91f58197c17 --- /dev/null +++ b/pkg/shadow_dom/tool/shadowdom.js @@ -0,0 +1,44 @@ +// Copyright 2013 The Polymer Authors. All rights reserved. +// Use of this source code is goverened by a BSD-style +// license that can be found in the LICENSE file. + +(function() { + var thisFile = 'shadowdom.js'; + var base = ''; + Array.prototype.forEach.call(document.querySelectorAll('script[src]'), function(s) { + var src = s.getAttribute('src'); + var re = new RegExp(thisFile + '[^\\\\]*'); + var match = src.match(re); + if (match) { + base = src.slice(0, -match[0].length); + } + }); + base += '../../../third_party/polymer/ShadowDOM/src/'; + + [ + 'sidetable.js', + 'wrappers.js', + 'wrappers/events.js', + 'wrappers/NodeList.js', + 'wrappers/Node.js', + 'querySelector.js', + 'wrappers/node-interfaces.js', + 'wrappers/CharacterData.js', + 'wrappers/Element.js', + 'wrappers/HTMLElement.js', + 'wrappers/HTMLContentElement.js', + 'wrappers/HTMLShadowElement.js', + 'wrappers/HTMLTemplateElement.js', + 'wrappers/HTMLUnknownElement.js', + 'wrappers/generic.js', + 'wrappers/ShadowRoot.js', + 'ShadowRenderer.js', + 'wrappers/Document.js', + 'wrappers/Window.js', + 'wrappers/MutationObserver.js', + 'wrappers/override-constructors.js' + ].forEach(function(src) { + document.write(''); + }); + +})();