├── .eslintrc.json ├── .gitattributes ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md └── stale.yml ├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE.txt ├── README.md ├── RELEASING.md ├── externs ├── .gitignore ├── .npmignore ├── polymer-dom-api-externs.js ├── polymer-externs.js ├── polymer-iconset-externs.js ├── polymer-internal-shared-types.js ├── polymer-internal-types.html └── webcomponents-externs.js ├── gulpfile.js ├── index.html ├── interfaces.d.ts ├── lib ├── elements │ ├── array-selector.d.ts │ ├── array-selector.js │ ├── custom-style.d.ts │ ├── custom-style.js │ ├── dom-bind.d.ts │ ├── dom-bind.js │ ├── dom-if.d.ts │ ├── dom-if.js │ ├── dom-module.d.ts │ ├── dom-module.js │ ├── dom-repeat.d.ts │ └── dom-repeat.js ├── legacy │ ├── class.d.ts │ ├── class.js │ ├── legacy-data-mixin.d.ts │ ├── legacy-data-mixin.js │ ├── legacy-element-mixin.d.ts │ ├── legacy-element-mixin.js │ ├── mutable-data-behavior.d.ts │ ├── mutable-data-behavior.js │ ├── polymer-fn.d.ts │ ├── polymer-fn.js │ ├── polymer.dom.d.ts │ ├── polymer.dom.js │ ├── templatizer-behavior.d.ts │ └── templatizer-behavior.js ├── mixins │ ├── dir-mixin.d.ts │ ├── dir-mixin.js │ ├── disable-upgrade-mixin.d.ts │ ├── disable-upgrade-mixin.js │ ├── element-mixin.d.ts │ ├── element-mixin.js │ ├── gesture-event-listeners.d.ts │ ├── gesture-event-listeners.js │ ├── mutable-data.d.ts │ ├── mutable-data.js │ ├── properties-changed.d.ts │ ├── properties-changed.js │ ├── properties-mixin.d.ts │ ├── properties-mixin.js │ ├── property-accessors.d.ts │ ├── property-accessors.js │ ├── property-effects.d.ts │ ├── property-effects.js │ ├── strict-binding-parser.d.ts │ ├── strict-binding-parser.js │ ├── template-stamp.d.ts │ └── template-stamp.js └── utils │ ├── array-splice.d.ts │ ├── array-splice.js │ ├── async.d.ts │ ├── async.js │ ├── boot.d.ts │ ├── boot.js │ ├── case-map.d.ts │ ├── case-map.js │ ├── debounce.d.ts │ ├── debounce.js │ ├── flattened-nodes-observer.d.ts │ ├── flattened-nodes-observer.js │ ├── flush.d.ts │ ├── flush.js │ ├── gestures.d.ts │ ├── gestures.js │ ├── hide-template-controls.d.ts │ ├── hide-template-controls.js │ ├── html-tag.d.ts │ ├── html-tag.js │ ├── mixin.d.ts │ ├── mixin.js │ ├── path.d.ts │ ├── path.js │ ├── render-status.d.ts │ ├── render-status.js │ ├── resolve-url.d.ts │ ├── resolve-url.js │ ├── scope-subtree.d.ts │ ├── scope-subtree.js │ ├── settings.d.ts │ ├── settings.js │ ├── style-gather.d.ts │ ├── style-gather.js │ ├── telemetry.d.ts │ ├── telemetry.js │ ├── templatize.d.ts │ ├── templatize.js │ ├── unresolved.d.ts │ ├── unresolved.js │ ├── wrap.d.ts │ └── wrap.js ├── manifest.json ├── package-lock.json ├── package.json ├── polymer-element.d.ts ├── polymer-element.js ├── polymer-legacy.d.ts ├── polymer-legacy.js ├── test ├── .eslintignore ├── .eslintrc.json ├── perf │ ├── binding-expressions.html │ └── perf-tests.html ├── runner.html ├── smoke │ ├── alacarte-property-accessors.html │ ├── alacarte-property-effects-ordering.html │ ├── alacarte-property-effects.html │ ├── alacarte-template-stamp.html │ ├── behavior-mixin.html │ ├── data-table.html │ ├── dirty-check.html │ ├── disable-upgrade.html │ ├── disabled-attr-gestures.html │ ├── dom-if.html │ ├── gestures.html │ ├── html-tag.html │ ├── label-click.html │ ├── ordering-test.html │ ├── passive-gestures.html │ └── style-props │ │ ├── src │ │ ├── elements-defaults.js │ │ ├── elements.js │ │ ├── scopes.js │ │ └── settings.js │ │ └── test.html └── unit │ ├── array-selector-elements.js │ ├── array-selector.html │ ├── async.html │ ├── attributes-elements.js │ ├── attributes.html │ ├── behaviors.html │ ├── case-map.html │ ├── class-properties.html │ ├── configure.html │ ├── css-parse.html │ ├── custom-style-async-import.html │ ├── custom-style-async-import.js │ ├── custom-style-async.html │ ├── custom-style-import.js │ ├── custom-style-late.html │ ├── custom-style-scope-cache.html │ ├── custom-style.html │ ├── debounce.html │ ├── dir.html │ ├── disable-upgrade.html │ ├── dom-bind-elements1.js │ ├── dom-bind-elements2.js │ ├── dom-bind.html │ ├── dom-if-elements.js │ ├── dom-if.html │ ├── dom-repeat-elements.js │ ├── dom-repeat.html │ ├── dynamic-import.html │ ├── dynamic-imports │ ├── async-import.html │ ├── async.html │ ├── dynamic-element.js │ ├── inner-element.js │ └── outer-element.html │ ├── events-elements.js │ ├── events.html │ ├── flattened-nodes-observer.html │ ├── gestures-elements.js │ ├── gestures.html │ ├── globals.html │ ├── html-tag.html │ ├── importHref.html │ ├── inheritance.html │ ├── legacy-data.html │ ├── legacy-noattributes.html │ ├── legacy-undefined.html │ ├── logging.html │ ├── mixin-behaviors.html │ ├── mixin-utils.html │ ├── multi-style.html │ ├── path-effects-elements.js │ ├── path-effects.html │ ├── path.html │ ├── polymer-dom-nopatch.html │ ├── polymer-dom-observeNodes.html │ ├── polymer-dom.html │ ├── polymer-element-with-apply-import.js │ ├── polymer-element-with-apply.html │ ├── polymer.element.html │ ├── polymer.legacyelement.html │ ├── polymer.properties-mixin-with-property-accessors.html │ ├── polymer.properties-mixin.html │ ├── properties-changed.html │ ├── property-accessors.html │ ├── property-effects-elements.js │ ├── property-effects-template.html │ ├── property-effects.html │ ├── ready-attached-order-class.html │ ├── ready-attached-order.html │ ├── render-status.html │ ├── resolveurl.html │ ├── shady-content.html │ ├── shady-dynamic.html │ ├── shady-events.html │ ├── shady-unscoped-style-import.js │ ├── shady-unscoped-style.html │ ├── shady.html │ ├── strict-template-policy.html │ ├── styling-build-adopted-stylesheets.html │ ├── styling-cross-scope-apply.html │ ├── styling-cross-scope-unknown-host.html │ ├── styling-cross-scope-var.html │ ├── styling-import-host2.css │ ├── styling-import-shared-styles.js │ ├── styling-only-with-template.html │ ├── styling-scoped-nopatch.html │ ├── styling-scoped.html │ ├── sub │ ├── resolveurl-elements.js │ ├── style-import.js │ ├── x-sub.html │ └── x-test.html │ ├── template-stamp.html │ ├── template-whitespace.html │ ├── templatize-elements.js │ ├── templatize.html │ └── wct-browser-config.js ├── util ├── .eslintrc.json ├── gen-changelog.sh ├── minimalDocument.js └── travis-sauce-test.sh └── wct.conf.json /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "eslint:recommended", 3 | "parser": "babel-eslint", 4 | "parserOptions": { 5 | "ecmaVersion": 6, 6 | "sourceType": "module" 7 | }, 8 | "rules": { 9 | "no-console": "off", 10 | "no-var": "error", 11 | "semi": "error", 12 | "strict": "error", 13 | "valid-jsdoc": ["error", { 14 | "requireReturn": false, 15 | "prefer": { 16 | "arg": "param", 17 | "argument": "param", 18 | "returns": "return" 19 | }, 20 | "preferType": { 21 | "Boolean": "boolean", 22 | "Number": "number", 23 | "String": "string", 24 | "object": "Object", 25 | "array": "Array" 26 | } 27 | }], 28 | "no-useless-escape": "off" 29 | }, 30 | "env": { 31 | "browser": true, 32 | "es6": true 33 | }, 34 | "plugins": [ 35 | "html" 36 | ], 37 | "globals": { 38 | "customElements": true, 39 | "HTMLImports": true, 40 | "Polymer": true, 41 | "ShadyDOM": true, 42 | "ShadyCSS": true, 43 | "JSCompiler_renameProperty": true, 44 | "trustedTypes": true 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Code owners for Polymer 2 | * @sorvell @kevinpschaaf @azakus 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 7 | 8 | ### Description 9 | 10 | 11 | #### Live Demo 12 | 13 | https://jsbin.com/luhaxab/edit 14 | 15 | https://glitch.com/edit/#!/polymer-repro?path=my-element.html:2:0 16 | 17 | 18 | #### Steps to Reproduce 19 | 27 | 28 | 29 | #### Expected Results 30 | 31 | 32 | #### Actual Results 33 | 34 | 35 | ### Browsers Affected 36 | 37 | - [ ] Chrome 38 | - [ ] Firefox 39 | - [ ] Edge 40 | - [ ] Safari 11 41 | - [ ] Safari 10 42 | - [ ] IE 11 43 | 44 | ### Versions 45 | 49 | - Polymer: vX.X.X 50 | - webcomponents: vX.X.X 51 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | ### Reference Issue 3 | 4 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Mark issues stale after 1 year 2 | daysUntilStale: 365 3 | # Delete stale issues after 2 years 4 | daysUntilClose: 730 5 | markComment: > 6 | This issue has been automatically marked as stale because it has not had 7 | recent activity. It will be closed if no further activity occurs. Thank you 8 | for your contributions. 9 | closeComment: > 10 | This issue has been automatically closed after being marked stale. If you're 11 | still facing this problem with the above solution, please comment and we'll 12 | reopen! 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | bower_components 3 | node_modules 4 | 5 | # compiled output 6 | dist 7 | 8 | # IDEs 9 | .idea 10 | .vscode 11 | 12 | # misc 13 | .DS_Store 14 | npm-debug.log 15 | 16 | # Analyzer output used in the docs 17 | analysis.json 18 | 19 | # NPM artifact 20 | polymer-polymer-*.tgz 21 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | sudo: false 3 | dist: xenial 4 | node_js: '10' 5 | services: 6 | - xvfb 7 | addons: 8 | firefox: latest 9 | chrome: stable 10 | cache: 11 | directories: 12 | - node_modules 13 | before_script: 14 | - npm install -g gulp-cli@1 15 | - gulp lint-eslint 16 | script: 17 | - node ./node_modules/.bin/polymer test --npm --module-resolution=node -l chrome 18 | - node ./node_modules/.bin/polymer test --npm --module-resolution=node -l firefox 19 | - if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then travis_wait 30 ./util/travis-sauce-test.sh; fi 20 | env: 21 | global: 22 | - secure: bfF/o1ewpOxDNqTzWfvlwgRgGfP8OXhSQLLdEwZ6izO9tckMJuSNghk3qBXCEQJwTcUEyXP6EqfzIrRAvDXPa0H3OoinbrooDyV2wIDaVRK++WR2iZIqzqo3hGOdzm4tdrGJZe5av5Rk661Hls8aPfLbjdzcGuYXi8B4wZq2xMI= 23 | - secure: jBrKtQBdoL2dsXi9BQpw5tMkYZOsQAy2iSB+0xPOxhPI8EbXKnm8OhWQDEJ5TdduLWUxLLc12IJwjBy9ocLlC1ZvzgOXNfqOUkLD03qSPnyT/LomTXeP4XuojUAemc/w1MHd61nFz4YJaO8cQ+yfy6GOX2susabW+Y80mnIeGJk= 24 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 The Polymer Authors. All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are 5 | // met: 6 | // 7 | // * Redistributions of source code must retain the above copyright 8 | // notice, this list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above 10 | // copyright notice, this list of conditions and the following disclaimer 11 | // in the documentation and/or other materials provided with the 12 | // distribution. 13 | // * Neither the name of Google Inc. nor the names of its 14 | // contributors may be used to endorse or promote products derived from 15 | // this software without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /RELEASING.md: -------------------------------------------------------------------------------- 1 | ## How to release a new version of Polymer 2 | 3 | - `npm ci` 4 | - `npm i -g np` 5 | - `npx gulp update-version` 6 | - Update CHANGELOG.md 7 | - Edit package.json back to the previous version so that `np` can be the one 8 | to bump the version. 9 | - `np --yolo --preview` 10 | - Ensures that you have permission, does a final check of all the steps. 11 | - `npm pack` and diff the tgz's contents against the previous version's. 12 | We release a new version of Polymer rarely enough that it's worth it to be 13 | careful. 14 | - `np --yolo` 15 | - After it completes successfully it will open the GitHub releases page for 16 | your new version. Edit the changelist there to remove irrelevent entries and publish. 17 | -------------------------------------------------------------------------------- /externs/.gitignore: -------------------------------------------------------------------------------- 1 | # TODO(timvdlippe): Ignore all files here once we can generate them. 2 | # * 3 | !.gitignore 4 | !.npmignore 5 | closure-types.js 6 | -------------------------------------------------------------------------------- /externs/.npmignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Polymer/polymer/26171d33853460066fb866e4c72a5b2d3b758e2a/externs/.npmignore -------------------------------------------------------------------------------- /externs/polymer-iconset-externs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @externs 3 | * @fileoverview Externs for Polymer.Iconset. 4 | */ 5 | 6 | /** 7 | * The interface that iconsets should obey. Iconsets are registered by setting 8 | * their name in the IronMeta 'iconset' db, and a value of type Polymer.Iconset. 9 | * 10 | * Used by iron-icon but needs to live here since iron-icon, iron-iconset, etc don't 11 | * depend on each other at all and talk only through iron-meta. 12 | * 13 | * @interface 14 | */ 15 | Polymer.Iconset = function() {}; 16 | 17 | /** 18 | * Applies an icon to the given element as a css background image. This 19 | * method does not size the element, and it's usually necessary to set 20 | * the element's height and width so that the background image is visible. 21 | * 22 | * @param {Element} element The element to which the icon is applied. 23 | * @param {string} icon The name of the icon to apply. 24 | * @param {string=} theme (optional) The name or index of the icon to apply. 25 | * @param {number=} scale (optional, defaults to 1) Icon scaling factor. 26 | */ 27 | Polymer.Iconset.prototype.applyIcon = function( 28 | element, icon, theme, scale) {}; 29 | 30 | /** 31 | * Remove an icon from the given element by undoing the changes effected 32 | * by `applyIcon`. 33 | * 34 | * @param {Element} element The element from which the icon is removed. 35 | */ 36 | Polymer.Iconset.prototype.removeIcon = function(element) {}; 37 | -------------------------------------------------------------------------------- /externs/polymer-internal-types.html: -------------------------------------------------------------------------------- 1 | 10 | 11 | -------------------------------------------------------------------------------- /externs/webcomponents-externs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Externs for webcomponents polyfills 3 | * @externs 4 | * @suppress {duplicate} 5 | * 6 | * @license 7 | * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. 8 | * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 9 | * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 10 | * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 11 | * Code distributed by Google as part of the polymer project is also 12 | * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 13 | */ 14 | /* eslint-disable */ 15 | 16 | var HTMLImports = {}; 17 | 18 | /** 19 | * @param {function()=} callback 20 | */ 21 | HTMLImports.whenReady = function(callback) {}; 22 | 23 | /** 24 | * Returns the import document containing the element. 25 | * @param {!Node} element 26 | * @return {?HTMLLinkElement|?Document|undefined} 27 | */ 28 | HTMLImports.importForElement = function(element) {}; 29 | 30 | window.HTMLImports = HTMLImports; 31 | 32 | var ShadyDOM = {}; 33 | 34 | ShadyDOM.inUse; 35 | ShadyDOM.composedPath; 36 | 37 | ShadyDOM.flush = function() {}; 38 | 39 | /** 40 | * @param {!Node} target 41 | * @param {function(Array, MutationObserver)} callback 42 | * @return {MutationObserver} 43 | */ 44 | ShadyDOM.observeChildren = function(target, callback) {}; 45 | 46 | /** 47 | * @param {MutationObserver} observer 48 | */ 49 | ShadyDOM.unobserveChildren = function(observer) {}; 50 | 51 | /** 52 | * @param {Node} node 53 | */ 54 | ShadyDOM.patch = function(node) {}; 55 | 56 | /** 57 | * @param {!ShadowRoot} shadowroot 58 | */ 59 | ShadyDOM.flushInitial = function(shadowroot) {}; 60 | 61 | window.ShadyDOM = ShadyDOM; 62 | 63 | var WebComponents = {}; 64 | window.WebComponents = WebComponents; 65 | 66 | /** @type {Element} */ 67 | HTMLElement.prototype._activeElement; 68 | 69 | /** 70 | * @param {HTMLTemplateElement} template 71 | */ 72 | HTMLTemplateElement.decorate = function(template){}; 73 | 74 | /** 75 | * @param {function(function())} cb callback 76 | */ 77 | CustomElementRegistry.prototype.polyfillWrapFlushCallback = function(cb){}; 78 | 79 | /** 80 | * @param {string} cssText 81 | */ 82 | CSSStyleSheet.prototype.replaceSync = function(cssText) {}; 83 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /lib/elements/custom-style.d.ts: -------------------------------------------------------------------------------- 1 | // tslint:disable:variable-name Describing an API that's defined elsewhere. 2 | 3 | import {cssFromModules} from '../utils/style-gather.js'; 4 | 5 | export {CustomStyle}; 6 | 7 | /** 8 | * Custom element for defining styles in the main document that can take 9 | * advantage of [shady DOM](https://github.com/webcomponents/shadycss) shims 10 | * for style encapsulation, custom properties, and custom mixins. 11 | * 12 | * - Document styles defined in a `` are shimmed to ensure they 13 | * do not leak into local DOM when running on browsers without native 14 | * Shadow DOM. 15 | * - Custom properties can be defined in a ``. Use the `html` selector 16 | * to define custom properties that apply to all custom elements. 17 | * - Custom mixins can be defined in a ``, if you import the optional 18 | * [apply shim](https://github.com/webcomponents/shadycss#about-applyshim) 19 | * (`shadycss/apply-shim.html`). 20 | * 21 | * To use: 22 | * 23 | * - Import `custom-style.html`. 24 | * - Place a `` element in the main document, wrapping an inline ` 45 | * 46 | * ``` 47 | */ 48 | declare class CustomStyle extends HTMLElement { 49 | 50 | /** 51 | * Returns the light-DOM ` 56 | * 57 | * ``` 58 | * 59 | * @customElement 60 | * @extends HTMLElement 61 | * @summary Custom element for defining styles in the main document that can 62 | * take advantage of Polymer's style scoping and custom properties shims. 63 | */ 64 | export class CustomStyle extends HTMLElement { 65 | constructor() { 66 | super(); 67 | this._style = null; 68 | CustomStyleInterface.addCustomStyle(this); 69 | } 70 | /** 71 | * Returns the light-DOM ` 46 | *
${this.partialTemplate}
47 | * ${super.template} 48 | * `; 49 | * } 50 | * static get partialTemplate() { return html`Partial!`; } 51 | * 52 | * @returns Constructed HTMLTemplateElement 53 | */ 54 | declare function html(strings: TemplateStringsArray, ...values: any[]): HTMLTemplateElement; 55 | 56 | export {htmlLiteral}; 57 | 58 | 59 | /** 60 | * An html literal tag that can be used with `html` to compose. 61 | * a literal string. 62 | * 63 | * Example: 64 | * 65 | * static get template() { 66 | * return html` 67 | * 71 | *
${staticValue}
72 | * ${super.template} 73 | * `; 74 | * } 75 | * static get styleTemplate() { 76 | * return htmlLiteral`.shadowed { background: gray; }`; 77 | * } 78 | * 79 | * @returns Constructed literal string 80 | */ 81 | declare function htmlLiteral(strings: TemplateStringsArray, ...values: any[]): LiteralString; 82 | -------------------------------------------------------------------------------- /lib/utils/mixin.d.ts: -------------------------------------------------------------------------------- 1 | // tslint:disable:variable-name Describing an API that's defined elsewhere. 2 | 3 | export {dedupingMixin}; 4 | 5 | 6 | /** 7 | * Wraps an ES6 class expression mixin such that the mixin is only applied 8 | * if it has not already been applied its base argument. Also memoizes mixin 9 | * applications. 10 | */ 11 | declare function dedupingMixin(mixin: T): T; 12 | -------------------------------------------------------------------------------- /lib/utils/mixin.js: -------------------------------------------------------------------------------- 1 | /** 2 | @license 3 | Copyright (c) 2017 The Polymer Project Authors. All rights reserved. 4 | This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 5 | The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 6 | The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 7 | Code distributed by Google as part of the polymer project is also 8 | subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 9 | */ 10 | import './boot.js'; 11 | 12 | // unique global id for deduping mixins. 13 | let dedupeId = 0; 14 | 15 | /** 16 | * @constructor 17 | * @extends {Function} 18 | * @private 19 | */ 20 | function MixinFunction(){} 21 | /** @type {(WeakMap | undefined)} */ 22 | MixinFunction.prototype.__mixinApplications; 23 | /** @type {(Object | undefined)} */ 24 | MixinFunction.prototype.__mixinSet; 25 | 26 | /* eslint-disable valid-jsdoc */ 27 | /** 28 | * Wraps an ES6 class expression mixin such that the mixin is only applied 29 | * if it has not already been applied its base argument. Also memoizes mixin 30 | * applications. 31 | * 32 | * @template T 33 | * @param {T} mixin ES6 class expression mixin to wrap 34 | * @return {T} 35 | * @suppress {invalidCasts} 36 | */ 37 | export const dedupingMixin = function(mixin) { 38 | let mixinApplications = /** @type {!MixinFunction} */(mixin).__mixinApplications; 39 | if (!mixinApplications) { 40 | mixinApplications = new WeakMap(); 41 | /** @type {!MixinFunction} */(mixin).__mixinApplications = mixinApplications; 42 | } 43 | // maintain a unique id for each mixin 44 | let mixinDedupeId = dedupeId++; 45 | function dedupingMixin(base) { 46 | let baseSet = /** @type {!MixinFunction} */(base).__mixinSet; 47 | if (baseSet && baseSet[mixinDedupeId]) { 48 | return base; 49 | } 50 | let map = mixinApplications; 51 | let extended = map.get(base); 52 | if (!extended) { 53 | extended = /** @type {!Function} */(mixin)(base); 54 | map.set(base, extended); 55 | // copy inherited mixin set from the extended class, or the base class 56 | // NOTE: we avoid use of Set here because some browser (IE11) 57 | // cannot extend a base Set via the constructor. 58 | let mixinSet = Object.create(/** @type {!MixinFunction} */(extended).__mixinSet || baseSet || null); 59 | mixinSet[mixinDedupeId] = true; 60 | /** @type {!MixinFunction} */(extended).__mixinSet = mixinSet; 61 | } 62 | return extended; 63 | } 64 | 65 | return dedupingMixin; 66 | }; 67 | /* eslint-enable valid-jsdoc */ 68 | -------------------------------------------------------------------------------- /lib/utils/path.d.ts: -------------------------------------------------------------------------------- 1 | // tslint:disable:variable-name Describing an API that's defined elsewhere. 2 | // tslint:disable:no-any describes the API as best we are able today 3 | 4 | export {isPath}; 5 | 6 | 7 | /** 8 | * Returns true if the given string is a structured data path (has dots). 9 | * 10 | * Example: 11 | * 12 | * ``` 13 | * isPath('foo.bar.baz') // true 14 | * isPath('foo') // false 15 | * ``` 16 | * 17 | * @returns True if the string contained one or more dots 18 | */ 19 | declare function isPath(path: string): boolean; 20 | 21 | export {root}; 22 | 23 | 24 | /** 25 | * Returns the root property name for the given path. 26 | * 27 | * Example: 28 | * 29 | * ``` 30 | * root('foo.bar.baz') // 'foo' 31 | * root('foo') // 'foo' 32 | * ``` 33 | * 34 | * @returns Root property name 35 | */ 36 | declare function root(path: string): string; 37 | 38 | export {isAncestor}; 39 | 40 | 41 | /** 42 | * Given `base` is `foo.bar`, `foo` is an ancestor, `foo.bar` is not 43 | * Returns true if the given path is an ancestor of the base path. 44 | * 45 | * Example: 46 | * 47 | * ``` 48 | * isAncestor('foo.bar', 'foo') // true 49 | * isAncestor('foo.bar', 'foo.bar') // false 50 | * isAncestor('foo.bar', 'foo.bar.baz') // false 51 | * ``` 52 | * 53 | * @returns True if `path` is an ancestor of `base`. 54 | */ 55 | declare function isAncestor(base: string, path: string): boolean; 56 | 57 | export {isDescendant}; 58 | 59 | 60 | /** 61 | * Given `base` is `foo.bar`, `foo.bar.baz` is an descendant 62 | * 63 | * Example: 64 | * 65 | * ``` 66 | * isDescendant('foo.bar', 'foo.bar.baz') // true 67 | * isDescendant('foo.bar', 'foo.bar') // false 68 | * isDescendant('foo.bar', 'foo') // false 69 | * ``` 70 | * 71 | * @returns True if `path` is a descendant of `base`. 72 | */ 73 | declare function isDescendant(base: string, path: string): boolean; 74 | 75 | export {translate}; 76 | 77 | 78 | /** 79 | * Replaces a previous base path with a new base path, preserving the 80 | * remainder of the path. 81 | * 82 | * User must ensure `path` has a prefix of `base`. 83 | * 84 | * Example: 85 | * 86 | * ``` 87 | * translate('foo.bar', 'zot', 'foo.bar.baz') // 'zot.baz' 88 | * ``` 89 | * 90 | * @returns Translated string 91 | */ 92 | declare function translate(base: string, newBase: string, path: string): string; 93 | 94 | export {matches}; 95 | 96 | 97 | /** 98 | * @returns True if `path` is equal to `base` 99 | */ 100 | declare function matches(base: string, path: string): boolean; 101 | 102 | export {normalize}; 103 | 104 | 105 | /** 106 | * Converts array-based paths to flattened path. String-based paths 107 | * are returned as-is. 108 | * 109 | * Example: 110 | * 111 | * ``` 112 | * normalize(['foo.bar', 0, 'baz']) // 'foo.bar.0.baz' 113 | * normalize('foo.bar.0.baz') // 'foo.bar.0.baz' 114 | * ``` 115 | * 116 | * @returns Flattened path 117 | */ 118 | declare function normalize(path: string|Array): string; 119 | 120 | export {split}; 121 | 122 | 123 | /** 124 | * Splits a path into an array of property names. Accepts either arrays 125 | * of path parts or strings. 126 | * 127 | * Example: 128 | * 129 | * ``` 130 | * split(['foo.bar', 0, 'baz']) // ['foo', 'bar', '0', 'baz'] 131 | * split('foo.bar.0.baz') // ['foo', 'bar', '0', 'baz'] 132 | * ``` 133 | * 134 | * @returns Array of path parts 135 | */ 136 | declare function split(path: string|Array): string[]; 137 | 138 | export {get}; 139 | 140 | 141 | /** 142 | * Reads a value from a path. If any sub-property in the path is `undefined`, 143 | * this method returns `undefined` (will never throw. 144 | * 145 | * @returns Value at path, or `undefined` if the path could not be 146 | * fully dereferenced. 147 | */ 148 | declare function get(root: object|null, path: string|Array, info?: object|null): any; 149 | 150 | export {set}; 151 | 152 | 153 | /** 154 | * Sets a value to a path. If any sub-property in the path is `undefined`, 155 | * this method will no-op. 156 | * 157 | * @returns The normalized version of the input path 158 | */ 159 | declare function set(root: object|null, path: string|Array, value: any): string|undefined; 160 | -------------------------------------------------------------------------------- /lib/utils/render-status.d.ts: -------------------------------------------------------------------------------- 1 | // tslint:disable:variable-name Describing an API that's defined elsewhere. 2 | // tslint:disable:no-any describes the API as best we are able today 3 | 4 | export {flush}; 5 | 6 | 7 | /** 8 | * Flushes all `beforeNextRender` tasks, followed by all `afterNextRender` 9 | * tasks. 10 | */ 11 | declare function flush(): void; 12 | 13 | export {beforeNextRender}; 14 | 15 | 16 | /** 17 | * Enqueues a callback which will be run before the next render, at 18 | * `requestAnimationFrame` timing. 19 | * 20 | * This method is useful for enqueuing work that requires DOM measurement, 21 | * since measurement may not be reliable in custom element callbacks before 22 | * the first render, as well as for batching measurement tasks in general. 23 | * 24 | * Tasks in this queue may be flushed by calling `flush()`. 25 | */ 26 | declare function beforeNextRender(context: any, callback: (...p0: any[]) => void, args?: any[]): void; 27 | 28 | export {afterNextRender}; 29 | 30 | 31 | /** 32 | * Enqueues a callback which will be run after the next render, equivalent 33 | * to one task (`setTimeout`) after the next `requestAnimationFrame`. 34 | * 35 | * This method is useful for tuning the first-render performance of an 36 | * element or application by deferring non-critical work until after the 37 | * first paint. Typical non-render-critical work may include adding UI 38 | * event listeners and aria attributes. 39 | */ 40 | declare function afterNextRender(context: any, callback: (...p0: any[]) => void, args?: any[]): void; 41 | -------------------------------------------------------------------------------- /lib/utils/render-status.js: -------------------------------------------------------------------------------- 1 | /** 2 | @license 3 | Copyright (c) 2017 The Polymer Project Authors. All rights reserved. 4 | This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 5 | The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 6 | The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 7 | Code distributed by Google as part of the polymer project is also 8 | subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 9 | */ 10 | 11 | /** 12 | * Module for scheduling flushable pre-render and post-render tasks. 13 | * 14 | * @summary Module for scheduling flushable pre-render and post-render tasks. 15 | */ 16 | 17 | import './boot.js'; 18 | 19 | let scheduled = false; 20 | let beforeRenderQueue = []; 21 | let afterRenderQueue = []; 22 | 23 | function schedule() { 24 | scheduled = true; 25 | // before next render 26 | requestAnimationFrame(function() { 27 | scheduled = false; 28 | flushQueue(beforeRenderQueue); 29 | // after the render 30 | setTimeout(function() { 31 | runQueue(afterRenderQueue); 32 | }); 33 | }); 34 | } 35 | 36 | function flushQueue(queue) { 37 | while (queue.length) { 38 | callMethod(queue.shift()); 39 | } 40 | } 41 | 42 | function runQueue(queue) { 43 | for (let i=0, l=queue.length; i < l; i++) { 44 | callMethod(queue.shift()); 45 | } 46 | } 47 | 48 | function callMethod(info) { 49 | const context = info[0]; 50 | const callback = info[1]; 51 | const args = info[2]; 52 | try { 53 | callback.apply(context, args); 54 | } catch(e) { 55 | setTimeout(() => { 56 | throw e; 57 | }); 58 | } 59 | } 60 | 61 | /** 62 | * Flushes all `beforeNextRender` tasks, followed by all `afterNextRender` 63 | * tasks. 64 | * 65 | * @return {void} 66 | */ 67 | export function flush() { 68 | while (beforeRenderQueue.length || afterRenderQueue.length) { 69 | flushQueue(beforeRenderQueue); 70 | flushQueue(afterRenderQueue); 71 | } 72 | scheduled = false; 73 | } 74 | 75 | 76 | /** 77 | * Enqueues a callback which will be run before the next render, at 78 | * `requestAnimationFrame` timing. 79 | * 80 | * This method is useful for enqueuing work that requires DOM measurement, 81 | * since measurement may not be reliable in custom element callbacks before 82 | * the first render, as well as for batching measurement tasks in general. 83 | * 84 | * Tasks in this queue may be flushed by calling `flush()`. 85 | * 86 | * @param {*} context Context object the callback function will be bound to 87 | * @param {function(...*):void} callback Callback function 88 | * @param {!Array=} args An array of arguments to call the callback function with 89 | * @return {void} 90 | */ 91 | export function beforeNextRender(context, callback, args) { 92 | if (!scheduled) { 93 | schedule(); 94 | } 95 | beforeRenderQueue.push([context, callback, args]); 96 | } 97 | 98 | /** 99 | * Enqueues a callback which will be run after the next render, equivalent 100 | * to one task (`setTimeout`) after the next `requestAnimationFrame`. 101 | * 102 | * This method is useful for tuning the first-render performance of an 103 | * element or application by deferring non-critical work until after the 104 | * first paint. Typical non-render-critical work may include adding UI 105 | * event listeners and aria attributes. 106 | * 107 | * @param {*} context Context object the callback function will be bound to 108 | * @param {function(...*):void} callback Callback function 109 | * @param {!Array=} args An array of arguments to call the callback function with 110 | * @return {void} 111 | */ 112 | export function afterNextRender(context, callback, args) { 113 | if (!scheduled) { 114 | schedule(); 115 | } 116 | afterRenderQueue.push([context, callback, args]); 117 | } 118 | 119 | -------------------------------------------------------------------------------- /lib/utils/resolve-url.d.ts: -------------------------------------------------------------------------------- 1 | // tslint:disable:variable-name Describing an API that's defined elsewhere. 2 | 3 | export {resolveUrl}; 4 | 5 | 6 | /** 7 | * Resolves the given URL against the provided `baseUri'. 8 | * 9 | * Note that this function performs no resolution for URLs that start 10 | * with `/` (absolute URLs) or `#` (hash identifiers). For general purpose 11 | * URL resolution, use `window.URL`. 12 | * 13 | * @returns resolved URL 14 | */ 15 | declare function resolveUrl(url: string, baseURI?: string|null): string; 16 | 17 | export {resolveCss}; 18 | 19 | 20 | /** 21 | * Resolves any relative URL's in the given CSS text against the provided 22 | * `ownerDocument`'s `baseURI`. 23 | * 24 | * @returns Processed CSS text with resolved URL's 25 | */ 26 | declare function resolveCss(cssText: string, baseURI: string): string; 27 | 28 | export {pathFromUrl}; 29 | 30 | 31 | /** 32 | * Returns a path from a given `url`. The path includes the trailing 33 | * `/` from the url. 34 | * 35 | * @returns resolved path 36 | */ 37 | declare function pathFromUrl(url: string): string; 38 | -------------------------------------------------------------------------------- /lib/utils/resolve-url.js: -------------------------------------------------------------------------------- 1 | /** 2 | @license 3 | Copyright (c) 2017 The Polymer Project Authors. All rights reserved. 4 | This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 5 | The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 6 | The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 7 | Code distributed by Google as part of the polymer project is also 8 | subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 9 | */ 10 | import './boot.js'; 11 | 12 | let CSS_URL_RX = /(url\()([^)]*)(\))/g; 13 | let ABS_URL = /(^\/[^\/])|(^#)|(^[\w-\d]*:)/; 14 | let workingURL; 15 | let resolveDoc; 16 | /** 17 | * Resolves the given URL against the provided `baseUri'. 18 | * 19 | * Note that this function performs no resolution for URLs that start 20 | * with `/` (absolute URLs) or `#` (hash identifiers). For general purpose 21 | * URL resolution, use `window.URL`. 22 | * 23 | * @param {string} url Input URL to resolve 24 | * @param {?string=} baseURI Base URI to resolve the URL against 25 | * @return {string} resolved URL 26 | */ 27 | export function resolveUrl(url, baseURI) { 28 | if (url && ABS_URL.test(url)) { 29 | return url; 30 | } 31 | if (url === '//') { 32 | return url; 33 | } 34 | // Lazy feature detection. 35 | if (workingURL === undefined) { 36 | workingURL = false; 37 | try { 38 | const u = new URL('b', 'http://a'); 39 | u.pathname = 'c%20d'; 40 | workingURL = (u.href === 'http://a/c%20d'); 41 | } catch (e) { 42 | // silently fail 43 | } 44 | } 45 | if (!baseURI) { 46 | baseURI = document.baseURI || window.location.href; 47 | } 48 | if (workingURL) { 49 | try { 50 | return (new URL(url, baseURI)).href; 51 | } catch (e) { 52 | // Bad url or baseURI structure. Do not attempt to resolve. 53 | return url; 54 | } 55 | } 56 | // Fallback to creating an anchor into a disconnected document. 57 | if (!resolveDoc) { 58 | resolveDoc = document.implementation.createHTMLDocument('temp'); 59 | resolveDoc.base = resolveDoc.createElement('base'); 60 | resolveDoc.head.appendChild(resolveDoc.base); 61 | resolveDoc.anchor = resolveDoc.createElement('a'); 62 | resolveDoc.body.appendChild(resolveDoc.anchor); 63 | } 64 | resolveDoc.base.href = baseURI; 65 | resolveDoc.anchor.href = url; 66 | return resolveDoc.anchor.href || url; 67 | 68 | } 69 | 70 | /** 71 | * Resolves any relative URL's in the given CSS text against the provided 72 | * `ownerDocument`'s `baseURI`. 73 | * 74 | * @param {string} cssText CSS text to process 75 | * @param {string} baseURI Base URI to resolve the URL against 76 | * @return {string} Processed CSS text with resolved URL's 77 | */ 78 | export function resolveCss(cssText, baseURI) { 79 | return cssText.replace(CSS_URL_RX, function(m, pre, url, post) { 80 | return pre + '\'' + 81 | resolveUrl(url.replace(/["']/g, ''), baseURI) + 82 | '\'' + post; 83 | }); 84 | } 85 | 86 | /** 87 | * Returns a path from a given `url`. The path includes the trailing 88 | * `/` from the url. 89 | * 90 | * @param {string} url Input URL to transform 91 | * @return {string} resolved path 92 | */ 93 | export function pathFromUrl(url) { 94 | return url.substring(0, url.lastIndexOf('/') + 1); 95 | } 96 | -------------------------------------------------------------------------------- /lib/utils/scope-subtree.d.ts: -------------------------------------------------------------------------------- 1 | // tslint:disable:variable-name Describing an API that's defined elsewhere. 2 | 3 | export {scopeSubtree}; 4 | 5 | 6 | /** 7 | * Ensure that elements in a ShadowDOM container are scoped correctly. 8 | * This function is only needed when ShadyDOM is used and unpatched DOM APIs are used in third party code. 9 | * This can happen in noPatch mode or when specialized APIs like ranges or tables are used to mutate DOM. 10 | * 11 | * @returns Returns a new MutationObserver on `container` if `shouldObserve` is true. 12 | */ 13 | declare function scopeSubtree(container: Element, shouldObserve?: boolean): MutationObserver|null; 14 | -------------------------------------------------------------------------------- /lib/utils/scope-subtree.js: -------------------------------------------------------------------------------- 1 | /** 2 | @license 3 | Copyright (c) 2019 The Polymer Project Authors. All rights reserved. 4 | This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 5 | The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 6 | The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 7 | Code distributed by Google as part of the polymer project is also 8 | subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 9 | */ 10 | 11 | import './boot.js'; 12 | import {wrap} from './wrap.js'; 13 | 14 | const ShadyDOM = window.ShadyDOM; 15 | const ShadyCSS = window.ShadyCSS; 16 | 17 | /** 18 | * Return true if node scope is correct. 19 | * 20 | * @param {!Element} node Node to check scope 21 | * @param {!Node} scope Scope reference 22 | * @return {boolean} True if node is in scope 23 | */ 24 | function sameScope(node, scope) { 25 | return wrap(node).getRootNode() === scope; 26 | } 27 | 28 | /** 29 | * Ensure that elements in a ShadowDOM container are scoped correctly. 30 | * This function is only needed when ShadyDOM is used and unpatched DOM APIs are used in third party code. 31 | * This can happen in noPatch mode or when specialized APIs like ranges or tables are used to mutate DOM. 32 | * 33 | * @param {!Element} container Container element to scope 34 | * @param {boolean=} shouldObserve if true, start a mutation observer for added nodes to the container 35 | * @return {?MutationObserver} Returns a new MutationObserver on `container` if `shouldObserve` is true. 36 | */ 37 | export function scopeSubtree(container, shouldObserve = false) { 38 | // If using native ShadowDOM, abort 39 | if (!ShadyDOM || !ShadyCSS) { 40 | return null; 41 | } 42 | // ShadyCSS handles DOM mutations when ShadyDOM does not handle scoping itself 43 | if (!ShadyDOM['handlesDynamicScoping']) { 44 | return null; 45 | } 46 | const ScopingShim = ShadyCSS['ScopingShim']; 47 | // if ScopingShim is not available, abort 48 | if (!ScopingShim) { 49 | return null; 50 | } 51 | // capture correct scope for container 52 | const containerScope = ScopingShim['scopeForNode'](container); 53 | const root = wrap(container).getRootNode(); 54 | 55 | const scopify = (node) => { 56 | if (!sameScope(node, root)) { 57 | return; 58 | } 59 | // NOTE: native qSA does not honor scoped DOM, but it is faster, and the same behavior as Polymer v1 60 | const elements = Array.from(ShadyDOM['nativeMethods']['querySelectorAll'].call(node, '*')); 61 | elements.push(node); 62 | for (let i = 0; i < elements.length; i++) { 63 | const el = elements[i]; 64 | if (!sameScope(el, root)) { 65 | continue; 66 | } 67 | const currentScope = ScopingShim['currentScopeForNode'](el); 68 | if (currentScope !== containerScope) { 69 | if (currentScope !== '') { 70 | ScopingShim['unscopeNode'](el, currentScope); 71 | } 72 | ScopingShim['scopeNode'](el, containerScope); 73 | } 74 | } 75 | }; 76 | 77 | // scope everything in container 78 | scopify(container); 79 | 80 | if (shouldObserve) { 81 | const mo = new MutationObserver((mxns) => { 82 | for (let i = 0; i < mxns.length; i++) { 83 | const mxn = mxns[i]; 84 | for (let j = 0; j < mxn.addedNodes.length; j++) { 85 | const addedNode = mxn.addedNodes[j]; 86 | if (addedNode.nodeType === Node.ELEMENT_NODE) { 87 | scopify(addedNode); 88 | } 89 | } 90 | } 91 | }); 92 | mo.observe(container, {childList: true, subtree: true}); 93 | return mo; 94 | } else { 95 | return null; 96 | } 97 | } -------------------------------------------------------------------------------- /lib/utils/style-gather.d.ts: -------------------------------------------------------------------------------- 1 | // tslint:disable:variable-name Describing an API that's defined elsewhere. 2 | 3 | import {DomModule} from '../elements/dom-module.js'; 4 | 5 | import {resolveCss} from './resolve-url.js'; 6 | 7 | export {stylesFromModules}; 8 | 9 | 10 | /** 11 | * Returns a list of 15 | 16 | 17 | 18 | Perf is go. 19 | 20 | 21 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /test/smoke/alacarte-property-accessors.html: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 49 | 50 | 51 | 52 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /test/smoke/alacarte-property-effects-ordering.html: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 36 | 37 | 125 | 126 | 127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /test/smoke/alacarte-property-effects.html: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 34 | 35 | 81 | 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /test/smoke/alacarte-template-stamp.html: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 35 | 36 | 90 | 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /test/smoke/behavior-mixin.html: -------------------------------------------------------------------------------- 1 | | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 23 | 24 | 92 | 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /test/smoke/dirty-check.html: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 23 | 24 | 51 | 52 | 53 | 54 | 55 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /test/smoke/disable-upgrade.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 17 | 18 | 19 | 20 | 32 | 33 | 52 | 53 | 54 | 55 | 56 | 57 | 75 | 76 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /test/smoke/disabled-attr-gestures.html: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 25 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /test/smoke/dom-if.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 34 | 35 | 36 | 37 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /test/smoke/gestures.html: -------------------------------------------------------------------------------- 1 | 2 | 11 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 28 | 29 | 30 | 31 |
32 | 33 | 34 |
Click on me \o/ 1
35 |
Click on me \o/ 2
36 |
Click on me \o/ 3
37 |
Click on me \o/ 4
38 |
Click on me \o/ 5
39 |
40 | 41 | 42 | 43 | 48 | 49 | -------------------------------------------------------------------------------- /test/smoke/html-tag.html: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 54 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /test/smoke/label-click.html: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /test/smoke/passive-gestures.html: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 19 | 25 | 26 | 27 | 28 | 40 | 41 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /test/smoke/style-props/src/elements-defaults.js: -------------------------------------------------------------------------------- 1 | const $_documentContainer = document.createElement('div'); 2 | $_documentContainer.setAttribute('style', 'display: none;'); 3 | 4 | $_documentContainer.innerHTML = ``; 14 | 15 | document.head.appendChild($_documentContainer); 16 | -------------------------------------------------------------------------------- /test/smoke/style-props/src/elements.js: -------------------------------------------------------------------------------- 1 | import './elements-defaults.js'; 2 | import { Polymer } from '../../../../lib/legacy/polymer-fn.js'; 3 | import { html } from '../../../../lib/utils/html-tag.js'; 4 | Polymer({ 5 | _template: html` 6 | 48 |
x-s
49 |
50 |
--a
51 |
--b
52 |
--c
53 |
54 |
55 | `, 56 | 57 | is: 'x-s' 58 | }); 59 | Polymer({ 60 | _template: html` 61 | 96 |
x-ss
97 |
98 |
--a
99 |
100 |
101 | `, 102 | 103 | is: 'x-ss' 104 | }); 105 | -------------------------------------------------------------------------------- /test/smoke/style-props/src/settings.js: -------------------------------------------------------------------------------- 1 | import { Polymer } from '../../../../lib/legacy/polymer-fn.js'; 2 | import { html } from '../../../../lib/utils/html-tag.js'; 3 | const $_documentContainer = document.createElement('div'); 4 | $_documentContainer.setAttribute('style', 'display: none;'); 5 | 6 | $_documentContainer.innerHTML = ` 7 | 31 | `; 32 | 33 | document.head.appendChild($_documentContainer); 34 | Polymer({ 35 | _template: html` 36 | 60 |
61 | `, 62 | 63 | is: 'x-setting', 64 | 65 | listeners: { 66 | click: 'clickHandler' 67 | }, 68 | 69 | ready: function() { 70 | this.setting = this.textContent; 71 | const obj = { 72 | '--setting-color': 'var(' + this.setting + ')' 73 | } 74 | this.updateStyles(obj); 75 | }, 76 | 77 | clickHandler: function() { 78 | this.fire('setting-change', this.setting); 79 | } 80 | }); 81 | -------------------------------------------------------------------------------- /test/smoke/style-props/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | style properties 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 17 | 18 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /test/unit/array-selector-elements.js: -------------------------------------------------------------------------------- 1 | /** 2 | @license 3 | Copyright (c) 2017 The Polymer Project Authors. All rights reserved. 4 | This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 5 | The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 6 | The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 7 | Code distributed by Google as part of the polymer project is also 8 | subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 9 | */ 10 | import { Polymer } from '../../lib/legacy/polymer-fn.js'; 11 | 12 | Polymer({ 13 | is: 'observe-el', 14 | observers: [ 15 | 'singleChanged(singleSelected.*)', 16 | 'multiChanged(multiSelected.*)' 17 | ], 18 | singleChanged: function() {}, 19 | multiChanged: function() {} 20 | }); 21 | -------------------------------------------------------------------------------- /test/unit/case-map.html: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 40 | -------------------------------------------------------------------------------- /test/unit/class-properties.html: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 38 | 39 | -------------------------------------------------------------------------------- /test/unit/custom-style-async-import.html: -------------------------------------------------------------------------------- 1 | 10 | 11 | 18 | 19 | 20 | 30 | 36 | 37 | -------------------------------------------------------------------------------- /test/unit/custom-style-async-import.js: -------------------------------------------------------------------------------- 1 | import { Polymer } from '../../lib/legacy/polymer-fn.js'; 2 | 3 | const $_documentContainer = document.createElement('template'); 4 | 5 | $_documentContainer.innerHTML = ` 6 | 13 | 14 | 15 | 25 | `; 26 | 27 | document.body.appendChild($_documentContainer.content); 28 | 29 | Polymer({ 30 | is: 'x-client' 31 | }); 32 | -------------------------------------------------------------------------------- /test/unit/custom-style-async.html: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 34 | 35 | 41 | 42 | 43 | 44 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /test/unit/custom-style-import.js: -------------------------------------------------------------------------------- 1 | /** 2 | @license 3 | Copyright (c) 2017 The Polymer Project Authors. All rights reserved. 4 | This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 5 | The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 6 | The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 7 | Code distributed by Google as part of the polymer project is also 8 | subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 9 | */ 10 | 11 | import './sub/style-import.js'; 12 | const $_documentContainer = document.createElement('template'); 13 | $_documentContainer.setAttribute('style', 'display: none;'); 14 | 15 | $_documentContainer.innerHTML = ` 16 | 23 | 24 | 31 | 32 | 43 | `; 44 | 45 | document.head.appendChild($_documentContainer.content); 46 | -------------------------------------------------------------------------------- /test/unit/custom-style-late.html: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 28 | 29 | 30 | 41 | 42 | 43 | 44 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /test/unit/custom-style-scope-cache.html: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 27 | 28 | 29 | 38 | 44 | 45 | 46 | 47 | 48 | 49 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /test/unit/dom-bind-elements1.js: -------------------------------------------------------------------------------- 1 | /** 2 | @license 3 | Copyright (c) 2017 The Polymer Project Authors. All rights reserved. 4 | This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 5 | The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 6 | The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 7 | Code distributed by Google as part of the polymer project is also 8 | subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 9 | */ 10 | import { Polymer } from '../../lib/legacy/polymer-fn.js'; 11 | 12 | import { html } from '../../lib/utils/html-tag.js'; 13 | Polymer({ 14 | is: 'x-basic', 15 | properties: { 16 | notifyingvalue: { 17 | notify: true 18 | } 19 | } 20 | }); 21 | Polymer({ 22 | _template: html` 23 |
24 | `, 25 | 26 | is: 'x-content' 27 | }); 28 | Polymer({ 29 | _template: html` 30 | 31 | `, 32 | 33 | is: 'x-attach-dom-bind', 34 | 35 | attached: function() { 36 | var domBind = document.createElement('dom-bind'); 37 | var template = document.createElement('template'); 38 | 39 | domBind.appendChild(template); 40 | 41 | var span = document.createElement('span'); 42 | span.innerHTML = '{{hello}}'; 43 | 44 | template.content.appendChild(span); 45 | domBind.hello = 'hey'; 46 | 47 | this.$.local.appendChild(domBind); 48 | } 49 | }); 50 | Polymer({ 51 | _template: html` 52 | 53 | `, 54 | 55 | is: 'x-compose' 56 | }); 57 | Polymer({ 58 | is: 'x-produce-a', 59 | properties: { 60 | bindToText: { 61 | notify: true, 62 | value: 'this text is bound' 63 | } 64 | } 65 | }); 66 | -------------------------------------------------------------------------------- /test/unit/dom-bind-elements2.js: -------------------------------------------------------------------------------- 1 | /** 2 | @license 3 | Copyright (c) 2017 The Polymer Project Authors. All rights reserved. 4 | This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 5 | The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 6 | The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 7 | Code distributed by Google as part of the polymer project is also 8 | subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 9 | */ 10 | import { Polymer } from '../../lib/legacy/polymer-fn.js'; 11 | 12 | Polymer({ 13 | is: 'x-needs-host', 14 | attached: function() { 15 | if (!this.__dataHost) { 16 | throw "No dataHost at ready time"; 17 | } 18 | this.config = this.__dataHost.getAttribute('config'); 19 | } 20 | }); 21 | -------------------------------------------------------------------------------- /test/unit/dynamic-imports/async-import.html: -------------------------------------------------------------------------------- 1 | 2 | 11 | -------------------------------------------------------------------------------- /test/unit/dynamic-imports/async.html: -------------------------------------------------------------------------------- 1 | 2 | 11 | -------------------------------------------------------------------------------- /test/unit/dynamic-imports/dynamic-element.js: -------------------------------------------------------------------------------- 1 | /** 2 | @license 3 | Copyright (c) 2017 The Polymer Project Authors. All rights reserved. 4 | This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 5 | The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 6 | The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 7 | Code distributed by Google as part of the polymer project is also 8 | subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 9 | */ 10 | import '../../../polymer-legacy.js'; 11 | 12 | import { Polymer } from '../../../lib/legacy/polymer-fn.js'; 13 | import { html } from '../../../lib/utils/html-tag.js'; 14 | import { dom } from '../../../lib/legacy/polymer.dom.js'; 15 | Polymer({ 16 | _template: html` 17 | dynamic-element : 18 | `, 19 | 20 | is: 'dynamic-element', 21 | 22 | ready: function() { 23 | var url = this.resolveUrl('outer-element.html'); 24 | this.importHref(url, function() { 25 | this.$.outer = document.createElement('outer-element'); 26 | dom(this.root).appendChild(this.$.outer); 27 | this._hasContent = true; 28 | if (this._callback) { 29 | this._callback(); 30 | } 31 | }, function() { 32 | assert.fail('failed to load import', url); 33 | }); 34 | }, 35 | 36 | whenDynamicContentReady: function(callback) { 37 | this._callback = callback; 38 | if (this._hasContent) { 39 | this._callback(); 40 | } 41 | } 42 | }); 43 | -------------------------------------------------------------------------------- /test/unit/dynamic-imports/inner-element.js: -------------------------------------------------------------------------------- 1 | /** 2 | @license 3 | Copyright (c) 2017 The Polymer Project Authors. All rights reserved. 4 | This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 5 | The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 6 | The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 7 | Code distributed by Google as part of the polymer project is also 8 | subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 9 | */ 10 | import '../../../polymer-legacy.js'; 11 | 12 | import { Polymer } from '../../../lib/legacy/polymer-fn.js'; 13 | import { html } from '../../../lib/utils/html-tag.js'; 14 | Polymer({ 15 | _template: html` 16 | inner-element 17 | `, 18 | 19 | is: 'inner-element' 20 | }); 21 | -------------------------------------------------------------------------------- /test/unit/dynamic-imports/outer-element.html: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 21 | 22 | 23 | 31 | -------------------------------------------------------------------------------- /test/unit/events-elements.js: -------------------------------------------------------------------------------- 1 | /** 2 | @license 3 | Copyright (c) 2017 The Polymer Project Authors. All rights reserved. 4 | This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 5 | The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 6 | The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 7 | Code distributed by Google as part of the polymer project is also 8 | subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 9 | */ 10 | import { Base } from '../../polymer-legacy.js'; 11 | 12 | import { Polymer } from '../../lib/legacy/polymer-fn.js'; 13 | import { html } from '../../lib/utils/html-tag.js'; 14 | var EventLoggerImpl = { 15 | created: function() { 16 | this._handled = {}; 17 | this._removed = []; 18 | }, 19 | handle: function(e) { 20 | const order = e._handleOrder = e._handleOrder || []; 21 | order.push(this.localName); 22 | this._handled[e.currentTarget.localName] = e.type; 23 | }, 24 | unlisten: function(node, eventName, handler) { 25 | this._removed.push({target: node.localName, event: eventName}); 26 | Base.unlisten.call(this, node, eventName, handler); 27 | } 28 | }; 29 | Polymer({ 30 | is: 'x-listeners', 31 | behaviors: [EventLoggerImpl], 32 | listeners: { 33 | foo: 'handle', 34 | bar: 'missing' 35 | } 36 | }); 37 | Polymer({ 38 | _template: html` 39 |
40 | `, 41 | 42 | is: 'x-on', 43 | behaviors: [EventLoggerImpl] 44 | }); 45 | Polymer({ 46 | _template: html` 47 | 48 | `, 49 | 50 | is: 'x-order', 51 | behaviors: [EventLoggerImpl] 52 | }); 53 | Polymer({ 54 | _template: html` 55 |
56 | `, 57 | 58 | is: 'x-dynamic', 59 | behaviors: [EventLoggerImpl], 60 | 61 | setup: function() { 62 | this.listen(this, 'foo', 'handle'); 63 | this.listen(this.$.inner, 'foo', 'handle'); 64 | this.listen(this, 'bar', 'missing'); 65 | this.listen(this.$.inner, 'bar', 'missing'); 66 | }, 67 | 68 | teardown: function() { 69 | this.unlisten(this, 'foo', 'handle'); 70 | this.unlisten(this.$.inner, 'foo', 'handle'); 71 | this.unlisten(this, 'bar', 'missing'); 72 | this.unlisten(this.$.inner, 'bar', 'missing'); 73 | } 74 | }); 75 | Polymer({ 76 | is: 'x-double', 77 | behaviors: [EventLoggerImpl], 78 | ready: function() { 79 | this.fooChanged = sinon.spy(); 80 | }, 81 | setup: function() { 82 | this.listen(this, 'foo', 'fooChanged'); 83 | this.listen(this, 'foo', 'fooChanged'); 84 | }, 85 | teardown: function() { 86 | this.unlisten(this, 'foo', 'fooChanged'); 87 | } 88 | }); 89 | -------------------------------------------------------------------------------- /test/unit/globals.html: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 22 | 23 | 24 | 25 | 26 | 27 | 30 | 31 | 32 | 36 | 59 | 60 | 61 | 62 | 63 | 110 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /test/unit/importHref.html: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /test/unit/logging.html: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 36 | 37 | 55 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /test/unit/multi-style.html: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 26 | 27 | 28 | 29 | 30 | 44 | 45 | 46 | 47 | 48 | 57 | 58 | 60 | 61 | 62 | 63 | 125 | 126 | 127 | -------------------------------------------------------------------------------- /test/unit/path.html: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 82 | -------------------------------------------------------------------------------- /test/unit/polymer-element-with-apply-import.js: -------------------------------------------------------------------------------- 1 | /** 2 | @license 3 | Copyright (c) 2017 The Polymer Project Authors. All rights reserved. 4 | This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 5 | The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 6 | The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 7 | Code distributed by Google as part of the polymer project is also 8 | subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 9 | */ 10 | import { PolymerElement } from '../../polymer-element.js'; 11 | 12 | import '@webcomponents/shadycss/entrypoints/apply-shim.js'; 13 | import '../../lib/elements/custom-style.js'; 14 | import { html } from '../../lib/utils/html-tag.js'; 15 | class ApplyElement extends PolymerElement { 16 | static get template() { 17 | return html` 18 | 24 | `; 25 | } 26 | 27 | static get is() {return 'apply-element';} 28 | } 29 | customElements.define('apply-element', ApplyElement); 30 | class XOuter extends PolymerElement { 31 | static get template() { 32 | return html` 33 | 49 | 50 | `; 51 | } 52 | 53 | static get is() {return 'x-outer';} 54 | } 55 | customElements.define('x-outer', XOuter); 56 | -------------------------------------------------------------------------------- /test/unit/polymer-element-with-apply.html: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 29 | 30 | 31 | 32 | 35 | 36 | 37 | 38 | 41 | 42 | 43 | 66 | 67 | -------------------------------------------------------------------------------- /test/unit/shady-unscoped-style-import.js: -------------------------------------------------------------------------------- 1 | /** 2 | @license 3 | Copyright (c) 2017 The Polymer Project Authors. All rights reserved. 4 | This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 5 | The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 6 | The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 7 | Code distributed by Google as part of the polymer project is also 8 | subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 9 | */ 10 | 11 | const $_documentContainer = document.createElement('template'); 12 | $_documentContainer.setAttribute('style', 'display: none;'); 13 | 14 | $_documentContainer.innerHTML = ` 15 | 33 | 34 | `; 35 | 36 | document.head.appendChild($_documentContainer.content); 37 | -------------------------------------------------------------------------------- /test/unit/shady-unscoped-style.html: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 29 | 30 | 31 | 32 | 33 | 47 | 48 | 55 | 56 | 57 | 58 | 59 | 60 | 71 | 72 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /test/unit/styling-cross-scope-unknown-host.html: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 33 | 34 | 35 | 45 | 46 | 47 | 57 | 63 | 64 | 65 | 66 | 74 | 84 | 85 | 86 | 127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /test/unit/styling-import-host2.css: -------------------------------------------------------------------------------- 1 | /* 2 | @license 3 | Copyright (c) 2017 The Polymer Project Authors. All rights reserved. 4 | This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 5 | The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 6 | The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 7 | Code distributed by Google as part of the polymer project is also 8 | subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 9 | */ 10 | :host { 11 | display: block; 12 | border: 2px solid black; 13 | } -------------------------------------------------------------------------------- /test/unit/styling-import-shared-styles.js: -------------------------------------------------------------------------------- 1 | /** 2 | @license 3 | Copyright (c) 2017 The Polymer Project Authors. All rights reserved. 4 | This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 5 | The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 6 | The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 7 | Code distributed by Google as part of the polymer project is also 8 | subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 9 | */ 10 | 11 | const $_documentContainer = document.createElement('template'); 12 | $_documentContainer.setAttribute('style', 'display: none;'); 13 | 14 | $_documentContainer.innerHTML = ` 15 | 20 | 21 | 22 | 29 | `; 30 | 31 | document.head.appendChild($_documentContainer.content); 32 | -------------------------------------------------------------------------------- /test/unit/styling-only-with-template.html: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 30 | 31 | 32 | 33 | 38 | 39 | 40 |
41 | 42 | 43 | 44 | 55 | 56 | 79 | 80 | -------------------------------------------------------------------------------- /test/unit/sub/resolveurl-elements.js: -------------------------------------------------------------------------------- 1 | /** 2 | @license 3 | Copyright (c) 2017 The Polymer Project Authors. All rights reserved. 4 | This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 5 | The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 6 | The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 7 | Code distributed by Google as part of the polymer project is also 8 | subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 9 | */ 10 | import { html } from '../../../lib/utils/html-tag.js'; 11 | 12 | import { PolymerElement } from '../../../polymer-element.js'; 13 | import { DomModule } from '../../../lib/elements/dom-module.js'; 14 | import { Polymer } from '../../../lib/legacy/polymer-fn.js'; 15 | import { pathFromUrl } from '../../../lib/utils/resolve-url.js'; 16 | 17 | const $_documentContainer = document.createElement('template'); 18 | $_documentContainer.setAttribute('style', 'display: none;'); 19 | const baseAssetPath = pathFromUrl(import.meta.url); 20 | $_documentContainer.innerHTML = ``; 21 | document.head.appendChild($_documentContainer.content); 22 | 23 | class PR extends PolymerElement { 24 | static get template() { 25 | return html` 26 | 33 | 34 | 35 | Foo 36 | 37 | 38 | 39 | 40 | 41 | Foo 42 | Foo 43 |
44 | Foo 45 | Foo 46 | Foo 47 | `; 48 | } 49 | static get is() { return 'p-r'; } 50 | static get importMeta() { 51 | return import.meta; 52 | } 53 | } 54 | customElements.define(PR.is, PR); 55 | 56 | const PRHybrid = Polymer({ 57 | is: 'p-r-hybrid', 58 | _template: PR.template, 59 | importMeta: import.meta 60 | }); 61 | 62 | class PRAp extends PolymerElement { 63 | static get is() { return 'p-r-ap'; } 64 | } 65 | customElements.define(PRAp.is, PRAp); 66 | -------------------------------------------------------------------------------- /test/unit/sub/style-import.js: -------------------------------------------------------------------------------- 1 | import { pathFromUrl } from '../../../lib/utils/resolve-url.js'; 2 | 3 | const $_documentContainer = document.createElement('template'); 4 | $_documentContainer.setAttribute('style', 'display: none;'); 5 | const baseAssetPath = pathFromUrl(import.meta.url); 6 | $_documentContainer.innerHTML = ` 7 | 16 | 17 | 24 | `; 25 | 26 | document.head.appendChild($_documentContainer.content); 27 | -------------------------------------------------------------------------------- /test/unit/sub/x-sub.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 12 | -------------------------------------------------------------------------------- /test/unit/sub/x-test.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 11 | 12 | -------------------------------------------------------------------------------- /test/unit/template-stamp.html: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 34 | 35 | 49 | 50 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /test/unit/wct-browser-config.js: -------------------------------------------------------------------------------- 1 | window.WCT = { 2 | environmentScripts: [ 3 | 'stacky/lib/parsing.js', 4 | 'stacky/lib/formatting.js', 5 | 'stacky/lib/normalization.js', 6 | 'mocha/mocha.js', 7 | 'chai/chai.js', 8 | '@polymer/sinonjs/sinon.js', 9 | 'accessibility-developer-tools/dist/js/axs_testing.js', 10 | '@polymer/test-fixture/test-fixture.js' 11 | ] 12 | }; 13 | -------------------------------------------------------------------------------- /util/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "node": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /util/gen-changelog.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # @license 4 | # Copyright (c) 2017 The Polymer Project Authors. All rights reserved. 5 | # This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 6 | # The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 7 | # The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 8 | # Code distributed by Google as part of the polymer project is also 9 | # subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 10 | # 11 | 12 | PRETTY="- %s ([commit](https://github.com/Polymer/polymer/commit/%h))%n" 13 | start="$1" 14 | end="$2" 15 | 16 | enddate=`git log -1 ${end} --pretty="%ai" | cut -d ' ' -f 1` 17 | 18 | old="" 19 | if [ -e CHANGELOG.md ]; then 20 | old="`sed -e '1,2d' CHANGELOG.md`" 21 | fi 22 | 23 | cat > CHANGELOG.md < blankRx.test(dom5.getTextContent(t))); 34 | 35 | class MinimalDocTransform extends Transform { 36 | constructor() { 37 | super({objectMode: true}); 38 | } 39 | _transform(file, enc, cb) { 40 | let doc = parse5.parse(String(file.contents), {locationInfo: true}); 41 | let vulc = dom5.query(doc, p.AND(p.hasTagName('div'), p.hasAttr('by-polymer-bundler'), p.hasAttr('hidden'))); 42 | let charset = dom5.query(doc, p.AND(p.hasTagName('meta'), p.hasAttrValue('charset', 'UTF-8'))); 43 | 44 | if (charset) { 45 | dom5.remove(charset); 46 | } 47 | 48 | dom5.removeNodeSaveChildren(vulc); 49 | 50 | let scripts = dom5.queryAll(doc, p.hasTagName('script')); 51 | let collector = scripts[0]; 52 | let contents = [dom5.getTextContent(collector)]; 53 | for (let i = 1, s; i < scripts.length; i++) { 54 | s = scripts[i]; 55 | dom5.remove(s); 56 | contents.push(dom5.getTextContent(s)); 57 | } 58 | dom5.setTextContent(collector, contents.join('')); 59 | 60 | onlyOneLicense(doc); 61 | 62 | dom5.removeFakeRootElements(doc); 63 | 64 | dom5.nodeWalkAll(doc, isBlankNode).forEach((t) => dom5.remove(t)); 65 | 66 | file.contents = new Buffer(parse5.serialize(doc)); 67 | 68 | cb(null, file); 69 | } 70 | } 71 | 72 | module.exports = () => new MinimalDocTransform(); 73 | -------------------------------------------------------------------------------- /util/travis-sauce-test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # @license 4 | # Copyright (c) 2018 The Polymer Project Authors. All rights reserved. 5 | # This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 6 | # The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 7 | # The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 8 | # Code distributed by Google as part of the polymer project is also 9 | # subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 10 | # 11 | set -x 12 | node ./node_modules/.bin/polymer test --npm --module-resolution=node -s 'windows 10/microsoftedge@15' -s 'windows 10/microsoftedge@17' -s 'windows 8.1/internet explorer@11' -s 'macos 10.13/safari@11' -s 'macos 10.13/safari@12' -s 'macos 10.13/safari@13' -s 'Linux/chrome@41' -------------------------------------------------------------------------------- /wct.conf.json: -------------------------------------------------------------------------------- 1 | { 2 | "suites": ["test/runner.html"], 3 | "environmentImports": [ 4 | "test-fixture/test-fixture.html" 5 | ], 6 | "plugins": { 7 | "local": { 8 | "browserOptions": { 9 | "chrome": [ 10 | "headless", 11 | "disable-gpu", 12 | "no-sandbox" 13 | ] 14 | } 15 | } 16 | } 17 | } 18 | --------------------------------------------------------------------------------