diff options
Diffstat (limited to 'catapult/third_party/polymer/components/shadycss/tests/module')
11 files changed, 221 insertions, 0 deletions
diff --git a/catapult/third_party/polymer/components/shadycss/tests/module/css-parse.js b/catapult/third_party/polymer/components/shadycss/tests/module/css-parse.js new file mode 100644 index 00000000..386ff297 --- /dev/null +++ b/catapult/third_party/polymer/components/shadycss/tests/module/css-parse.js @@ -0,0 +1,17 @@ +/** +@license +Copyright (c) 2016 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +*/ + +/* +A simple shim to generate a testable module +*/ + +import * as CssParse from '../../src/css-parse' + +window['CssParse'] = CssParse; diff --git a/catapult/third_party/polymer/components/shadycss/tests/module/custom-style-element.js b/catapult/third_party/polymer/components/shadycss/tests/module/custom-style-element.js new file mode 100644 index 00000000..b306989c --- /dev/null +++ b/catapult/third_party/polymer/components/shadycss/tests/module/custom-style-element.js @@ -0,0 +1,15 @@ +/** +@license +Copyright (c) 2016 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +*/ + +/* +A simple shim to generate a testable module +*/ + +import '../../examples/custom-style-element' diff --git a/catapult/third_party/polymer/components/shadycss/tests/module/make-element.js b/catapult/third_party/polymer/components/shadycss/tests/module/make-element.js new file mode 100644 index 00000000..45eb3b3e --- /dev/null +++ b/catapult/third_party/polymer/components/shadycss/tests/module/make-element.js @@ -0,0 +1,35 @@ +/** +@license +Copyright (c) 2016 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +*/ + +/* +A simple webcomponents helper +*/ +'use strict'; + +window.makeElement = (name, connectedCallback) => { + let template = document.querySelector(`template#${name}`); + if (template && window.ShadyCSS) { + window.ShadyCSS.prepareTemplate(template, name); + } + window.customElements.define(name, class extends window.HTMLElement { + connectedCallback() { + window.ShadyCSS && window.ShadyCSS.styleElement(this); + if (!this.shadowRoot) { + this.attachShadow({mode: 'open'}); + if (template) { + this.shadowRoot.appendChild(template.content.cloneNode(true)); + } + } + if (connectedCallback) { + connectedCallback.call(this); + } + } + }); +}; diff --git a/catapult/third_party/polymer/components/shadycss/tests/module/style-cache.js b/catapult/third_party/polymer/components/shadycss/tests/module/style-cache.js new file mode 100644 index 00000000..cb5a46cf --- /dev/null +++ b/catapult/third_party/polymer/components/shadycss/tests/module/style-cache.js @@ -0,0 +1,16 @@ +/** +@license +Copyright (c) 2016 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +*/ + +/* +A simple shim to generate a testable module +*/ + +import StyleCache from '../../src/style-cache' +window['StyleCache'] = StyleCache; diff --git a/catapult/third_party/polymer/components/shadycss/tests/module/style-info.js b/catapult/third_party/polymer/components/shadycss/tests/module/style-info.js new file mode 100644 index 00000000..31e31843 --- /dev/null +++ b/catapult/third_party/polymer/components/shadycss/tests/module/style-info.js @@ -0,0 +1,16 @@ +/** +@license +Copyright (c) 2016 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +*/ + +/* +A simple shim to generate a testable module +*/ + +import StyleInfo from '../../src/style-info' +window['StyleInfo'] = StyleInfo; diff --git a/catapult/third_party/polymer/components/shadycss/tests/module/style-placeholder.js b/catapult/third_party/polymer/components/shadycss/tests/module/style-placeholder.js new file mode 100644 index 00000000..0c01f4b0 --- /dev/null +++ b/catapult/third_party/polymer/components/shadycss/tests/module/style-placeholder.js @@ -0,0 +1,15 @@ +/** +@license +Copyright (c) 2016 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +*/ + +/* +A simple shim to generate a testable module +*/ + +import '../../src/style-placeholder' diff --git a/catapult/third_party/polymer/components/shadycss/tests/module/style-properties.js b/catapult/third_party/polymer/components/shadycss/tests/module/style-properties.js new file mode 100644 index 00000000..054c4e73 --- /dev/null +++ b/catapult/third_party/polymer/components/shadycss/tests/module/style-properties.js @@ -0,0 +1,16 @@ +/** +@license +Copyright (c) 2016 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +*/ + +/* +A simple shim to generate a testable module +*/ + +import StyleProperties from '../../src/style-properties' +window['StyleProperties'] = StyleProperties; diff --git a/catapult/third_party/polymer/components/shadycss/tests/module/style-settings.js b/catapult/third_party/polymer/components/shadycss/tests/module/style-settings.js new file mode 100644 index 00000000..b73830b7 --- /dev/null +++ b/catapult/third_party/polymer/components/shadycss/tests/module/style-settings.js @@ -0,0 +1,16 @@ +/** +@license +Copyright (c) 2016 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +*/ + +/* +A simple shim to generate a testable module +*/ + +import * as StyleSettings from '../../src/style-settings' +window['StyleSettings'] = StyleSettings; diff --git a/catapult/third_party/polymer/components/shadycss/tests/module/style-transformer.js b/catapult/third_party/polymer/components/shadycss/tests/module/style-transformer.js new file mode 100644 index 00000000..77a4097a --- /dev/null +++ b/catapult/third_party/polymer/components/shadycss/tests/module/style-transformer.js @@ -0,0 +1,16 @@ +/** +@license +Copyright (c) 2016 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +*/ + +/* +A simple shim to generate a testable module +*/ + +import StyleTransformer from '../../src/style-transformer' +window['StyleTransformer'] = StyleTransformer; diff --git a/catapult/third_party/polymer/components/shadycss/tests/module/style-util.js b/catapult/third_party/polymer/components/shadycss/tests/module/style-util.js new file mode 100644 index 00000000..6b59a18c --- /dev/null +++ b/catapult/third_party/polymer/components/shadycss/tests/module/style-util.js @@ -0,0 +1,16 @@ +/** +@license +Copyright (c) 2016 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +*/ + +/* +A simple shim to generate a testable module +*/ + +import * as StyleUtil from '../../src/style-util' +window['StyleUtil'] = StyleUtil; diff --git a/catapult/third_party/polymer/components/shadycss/tests/module/svg-in-shadow.js b/catapult/third_party/polymer/components/shadycss/tests/module/svg-in-shadow.js new file mode 100644 index 00000000..502cd702 --- /dev/null +++ b/catapult/third_party/polymer/components/shadycss/tests/module/svg-in-shadow.js @@ -0,0 +1,43 @@ +/** +@license +Copyright (c) 2016 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +*/ + +'use strict'; + +const ShadyCSS = window.ShadyCSS; + +window.registerSVGElement = () => { + const LOCAL_NAME = 'svg-in-shadow'; + const TEMPLATE = document.querySelector(`template#${LOCAL_NAME}`); + ShadyCSS.prepareTemplate(TEMPLATE, LOCAL_NAME); + + class SVGInShadow extends window.HTMLElement { + connectedCallback() { + ShadyCSS.styleElement(this); + this.attachShadow({mode: 'open'}); + this.shadowRoot.appendChild(document.importNode(TEMPLATE.content, true)); + } + + get svg() { + return this.shadowRoot.querySelector('svg'); + } + + addCircle() { + const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle'); + const x = 10 + Math.floor(80 * Math.random()); + const y = 10 + Math.floor(80 * Math.random()); + circle.setAttribute('cx', String(x)); + circle.setAttribute('cy', String(y)); + circle.setAttribute('r', '10'); + this.svg.appendChild(circle); + return circle; + } + } + window.customElements.define(LOCAL_NAME, SVGInShadow); +};
\ No newline at end of file |