diff --git a/lib/elements/array-selector.js b/lib/elements/array-selector.js index 51b88d1705..c4926f52b9 100644 --- a/lib/elements/array-selector.js +++ b/lib/elements/array-selector.js @@ -29,8 +29,7 @@ import { ElementMixin } from '../mixins/element-mixin.js'; * * @polymer * @mixinFunction - * @appliesMixin Polymer.ElementMixin - * @memberof Polymer + * @appliesMixin ElementMixin * @summary Element mixin for recording dynamic associations between item paths in a * master `items` array and a `selected` array */ @@ -342,13 +341,13 @@ export { ArraySelectorMixin }; /** * @constructor - * @extends {Polymer.Element} + * @extends {PolymerElement} * @implements {Polymer_ArraySelectorMixin} */ let baseArraySelector = ArraySelectorMixin(PolymerElement); /** - * Element implementing the `Polymer.ArraySelector` mixin, which records + * Element implementing the `ArraySelector` mixin, which records * dynamic associations between item paths in a master `items` array and a * `selected` array such that path changes to the master array (at the host) * element or elsewhere via data-binding) are correctly propagated to items @@ -364,63 +363,60 @@ let baseArraySelector = ArraySelectorMixin(PolymerElement); * * Example: * - * ```html - * - * - * + * class EmployeeList extends PolymerElement { + * static get _template() { + * return html` + *
Employee list:
+ * + * + * * - *
- * ``` + * * - * ```js - *class EmployeeList extends Polymer.Element { - * static get is() { return 'employee-list'; } - * static get properties() { - * return { - * employees: { - * value() { - * return [ - * {first: 'Bob', last: 'Smith'}, - * {first: 'Sally', last: 'Johnson'}, - * ... - * ]; - * } - * } - * }; - * } - * toggleSelection(e) { - * let item = this.$.employeeList.itemForElement(e.target); - * this.$.selector.select(item); - * } - *} + *
Selected employees:
+ * + * + * `; + * } + * static get is() { return 'employee-list'; } + * static get properties() { + * return { + * employees: { + * value() { + * return [ + * {first: 'Bob', last: 'Smith'}, + * {first: 'Sally', last: 'Johnson'}, + * ... + * ]; + * } + * } + * }; + * } + * toggleSelection(e) { + * const item = this.$.employeeList.itemForElement(e.target); + * this.$.selector.select(item); + * } + * } * ``` * * @polymer * @customElement * @extends {baseArraySelector} - * @appliesMixin Polymer.ArraySelectorMixin - * @memberof Polymer + * @appliesMixin ArraySelectorMixin * @summary Custom element that links paths between an input `items` array and * an output `selected` item or array based on calls to its selection API. */ diff --git a/lib/elements/custom-style.js b/lib/elements/custom-style.js index 9af6bc5459..208c29e962 100644 --- a/lib/elements/custom-style.js +++ b/lib/elements/custom-style.js @@ -58,11 +58,10 @@ const CustomStyleInterface = window.ShadyCSS.CustomStyleInterface; * * @customElement * @extends HTMLElement - * @memberof Polymer * @summary Custom element for defining styles in the main document that can * take advantage of Polymer's style scoping and custom properties shims. */ -class CustomStyle extends HTMLElement { +export class CustomStyle extends HTMLElement { constructor() { super(); this._style = null; @@ -107,4 +106,3 @@ class CustomStyle extends HTMLElement { } window.customElements.define('custom-style', CustomStyle); -export { CustomStyle }; diff --git a/lib/elements/dom-bind.js b/lib/elements/dom-bind.js index b0a1abc14c..512e01c973 100644 --- a/lib/elements/dom-bind.js +++ b/lib/elements/dom-bind.js @@ -37,15 +37,14 @@ const domBindBase = * * @polymer * @customElement - * @appliesMixin Polymer.PropertyEffects - * @appliesMixin Polymer.OptionalMutableData - * @appliesMixin Polymer.GestureEventListeners + * @appliesMixin PropertyEffects + * @appliesMixin OptionalMutableData + * @appliesMixin GestureEventListeners * @extends {domBindBase} - * @memberof Polymer * @summary Custom element to allow using Polymer's template features (data * binding, declarative event listeners, etc.) in the main document. */ -class DomBind extends domBindBase { +export class DomBind extends domBindBase { static get observedAttributes() { return ['mutable-data']; } @@ -126,5 +125,3 @@ class DomBind extends domBindBase { } customElements.define('dom-bind', DomBind); - -export { DomBind }; diff --git a/lib/elements/dom-if.js b/lib/elements/dom-if.js index 1b3f20f07d..0b95ac568e 100644 --- a/lib/elements/dom-if.js +++ b/lib/elements/dom-if.js @@ -32,12 +32,11 @@ import { root as root$0 } from '../utils/path.js'; * * @customElement * @polymer - * @extends Polymer.Element - * @memberof Polymer + * @extends PolymerElement * @summary Custom element that conditionally stamps and hides or removes * template content based on a boolean flag. */ -class DomIf extends PolymerElement { +export class DomIf extends PolymerElement { // Not needed to find template; can be removed once the analyzer // can find the tag name from customElements.define call @@ -278,5 +277,3 @@ class DomIf extends PolymerElement { } customElements.define(DomIf.is, DomIf); - -export { DomIf }; diff --git a/lib/elements/dom-module.js b/lib/elements/dom-module.js index a16239e6b7..ae35fe99bb 100644 --- a/lib/elements/dom-module.js +++ b/lib/elements/dom-module.js @@ -44,12 +44,11 @@ function styleOutsideTemplateCheck(inst) { * * @customElement * @extends HTMLElement - * @memberof Polymer * @summary Custom element that provides a registry of relocatable DOM content * by `id` that is agnostic to bundling. * @unrestricted */ -class DomModule extends HTMLElement { +export class DomModule extends HTMLElement { static get observedAttributes() { return ['id']; } @@ -136,6 +135,3 @@ class DomModule extends HTMLElement { DomModule.prototype['modules'] = modules; customElements.define('dom-module', DomModule); - -// export -export { DomModule }; diff --git a/lib/elements/dom-repeat.js b/lib/elements/dom-repeat.js index 71b4c63724..1aa95cc101 100644 --- a/lib/elements/dom-repeat.js +++ b/lib/elements/dom-repeat.js @@ -21,7 +21,7 @@ let TemplateInstanceBase = TemplateInstanceBase$0; // eslint-disable-line /** * @constructor * @implements {Polymer_OptionalMutableData} - * @extends {Polymer.Element} + * @extends {PolymerElement} */ const domRepeatBase = OptionalMutableData(PolymerElement); @@ -56,7 +56,7 @@ const domRepeatBase = OptionalMutableData(PolymerElement); * With the following custom element definition: * * ```js - * class EmployeeList extends Polymer.Element { + * class EmployeeList extends PolymerElement { * static get is() { return 'employee-list'; } * static get properties() { * return { @@ -78,15 +78,14 @@ const domRepeatBase = OptionalMutableData(PolymerElement); * instances, which will update via the normal structured data notification system. * * Mutations to the `items` array itself should be made using the Array - * mutation API's on `Polymer.Base` (`push`, `pop`, `splice`, `shift`, - * `unshift`), and template instances will be kept in sync with the data in the - * array. + * mutation API's on the PropertyEffects mixin (`push`, `pop`, `splice`, + * `shift`, `unshift`), and template instances will be kept in sync with the + * data in the array. * * Events caught by event handlers within the `dom-repeat` template will be * decorated with a `model` property, which represents the binding scope for - * each template instance. The model is an instance of Polymer.Base, and should - * be used to manipulate data on the instance, for example - * `event.model.set('item.checked', true);`. + * each template instance. The model should be used to manipulate data on the + * instance, for example `event.model.set('item.checked', true);`. * * Alternatively, the model for a template instance for an element stamped by * a `dom-repeat` can be obtained using the `modelForElement` API on the @@ -123,13 +122,12 @@ const domRepeatBase = OptionalMutableData(PolymerElement); * * @customElement * @polymer - * @memberof Polymer * @extends {domRepeatBase} - * @appliesMixin Polymer.OptionalMutableData + * @appliesMixin OptionalMutableData * @summary Custom element for stamping instance of a template bound to * items in an array. */ -class DomRepeat extends domRepeatBase { +export class DomRepeat extends domRepeatBase { // Not needed to find template; can be removed once the analyzer // can find the tag name from customElements.define call @@ -707,7 +705,7 @@ class DomRepeat extends domRepeatBase { /** * Returns the template "model" associated with a given element, which * serves as the binding scope for the template instance the element is - * contained in. A template model is an instance of `Polymer.Base`, and + * contained in. A template model * should be used to manipulate data associated with this template instance. * * Example: @@ -728,5 +726,3 @@ class DomRepeat extends domRepeatBase { } customElements.define(DomRepeat.is, DomRepeat); - -export { DomRepeat }; diff --git a/lib/legacy/class.js b/lib/legacy/class.js index e1ac44c717..e9ebc474d2 100644 --- a/lib/legacy/class.js +++ b/lib/legacy/class.js @@ -26,19 +26,19 @@ let metaProps = { /** * Applies a "legacy" behavior or array of behaviors to the provided class. * - * Note: this method will automatically also apply the `Polymer.LegacyElementMixin` + * Note: this method will automatically also apply the `LegacyElementMixin` * to ensure that any legacy behaviors can rely on legacy Polymer API on * the underlying element. * + * @function * @template T * @param {!Object|!Array} behaviors Behavior object or array of behaviors. * @param {function(new:T)} klass Element class. * @return {function(new:T)} Returns a new Element class extended by the - * passed in `behaviors` and also by `Polymer.LegacyElementMixin`. - * @memberof Polymer + * passed in `behaviors` and also by `LegacyElementMixin`. * @suppress {invalidCasts, checkTypes} */ -function mixinBehaviors(behaviors, klass) { +export function mixinBehaviors(behaviors, klass) { if (!behaviors) { klass = /** @type {HTMLElement} */(klass); // eslint-disable-line no-self-assign return klass; @@ -85,7 +85,7 @@ function mixinBehaviors(behaviors, klass) { // element's prototype chain. Behaviors are placed in the element prototype // eldest to youngest and de-duped youngest to oldest: // So, first [A, B, C, A, B] becomes [C, A, B] then, -// the element prototype becomes (oldest) (1) Polymer.Element, (2) class(C), +// the element prototype becomes (oldest) (1) PolymerElement, (2) class(C), // (3) class(A), (4) class(B), (5) class(Polymer({...})). // Result: // This means element properties win over B properties win over A win @@ -286,7 +286,7 @@ function GenerateClassFromInfo(info, Base) { } /** - * Generates a class that extends `Polymer.LegacyElement` based on the + * Generates a class that extends `LegacyElement` based on the * provided info object. Metadata objects on the `info` object * (`properties`, `observers`, `listeners`, `behaviors`, `is`) are used * for Polymer's meta-programming systems, and any functions are copied @@ -354,7 +354,7 @@ function GenerateClassFromInfo(info, Base) { */ export const Class = function(info) { if (!info) { - console.warn('Polymer.Class requires `info` argument'); + console.warn(`Polymer's Class function requires \`info\` argument`); } let klass = GenerateClassFromInfo(info, info.behaviors ? // note: mixinBehaviors ensures `LegacyElementMixin`. @@ -364,5 +364,3 @@ export const Class = function(info) { klass.is = info.is; return klass; }; - -export { mixinBehaviors }; diff --git a/lib/legacy/polymer-fn.js b/lib/legacy/polymer-fn.js index 3651dcc44c..d3e12704cf 100644 --- a/lib/legacy/polymer-fn.js +++ b/lib/legacy/polymer-fn.js @@ -16,13 +16,15 @@ import '../utils/boot.js'; * elements. * * This method is equivalent to - * `customElements.define(info.is, Polymer.Class(info));` * - * See `Polymer.Class` for details on valid legacy metadata format for `info`. + * import {Class} from '@polymer/polymer/lib/legacy/class.js'; + * customElements.define(info.is, Class(info)); + * + * See `Class` for details on valid legacy metadata format for `info`. * * @global * @override - * @function Polymer + * @function * @param {!PolymerInit} info Object containing Polymer metadata and functions * to become class methods. * @return {function(new: HTMLElement)} Generated class diff --git a/lib/legacy/polymer.dom.js b/lib/legacy/polymer.dom.js index 9c4bfc637e..2d817e050c 100644 --- a/lib/legacy/polymer.dom.js +++ b/lib/legacy/polymer.dom.js @@ -25,12 +25,11 @@ const normalizedMatchesSelector = p.matches || p.matchesSelector || * Cross-platform `element.matches` shim. * * @function matchesSelector - * @memberof Polymer.dom * @param {!Node} node Node to check selector against * @param {string} selector Selector to match * @return {boolean} True if node matched selector */ -const matchesSelector = function(node, selector) { +export const matchesSelector = function(node, selector) { return normalizedMatchesSelector.call(node, selector); }; @@ -38,9 +37,8 @@ const matchesSelector = function(node, selector) { * Node API wrapper class returned from `Polymer.dom.(target)` when * `target` is a `Node`. * - * @memberof Polymer */ -class DomApi { +export class DomApi { /** * @param {Node} node Node for which to create a Polymer.dom helper object. @@ -287,8 +285,6 @@ class EventApi { } } -export { DomApi }; - /** * @function * @param {boolean=} deep @@ -375,8 +371,6 @@ export const dom = function(obj) { return obj.__domApi; }; -export { matchesSelector }; - /** * Forces several classes of asynchronously queued tasks to flush: * - Debouncers added via `Polymer.enqueueDebouncer` diff --git a/lib/legacy/templatizer-behavior.js b/lib/legacy/templatizer-behavior.js index 0677a0e118..f1b8f7fd2f 100644 --- a/lib/legacy/templatizer-behavior.js +++ b/lib/legacy/templatizer-behavior.js @@ -24,17 +24,18 @@ let TemplateInstanceBase = TemplateInstanceBase$0; // eslint-disable-line let TemplatizerUser; // eslint-disable-line /** - * The `Polymer.Templatizer` behavior adds methods to generate instances of - * templates that are each managed by an anonymous `Polymer.PropertyEffects` + * The `Templatizer` behavior adds methods to generate instances of + * templates that are each managed by an anonymous `PropertyEffects` * instance where data-bindings in the stamped template content are bound to * accessors on itself. * - * This behavior is provided in Polymer 2.x as a hybrid-element convenience - * only. For non-hybrid usage, the `Polymer.Templatize` library + * This behavior is provided in Polymer 2.x-3.x as a hybrid-element convenience + * only. For non-hybrid usage, the `Templatize` library * should be used instead. * * Example: * + * import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js'; * // Get a template from somewhere, e.g. light DOM * let template = this.querySelector('template'); * // Prepare the template @@ -42,7 +43,7 @@ let TemplatizerUser; // eslint-disable-line * // Instance the template with an initial data model * let instance = this.stamp({myProp: 'initial'}); * // Insert the instance's DOM somewhere, e.g. light DOM - * Polymer.dom(this).appendChild(instance.root); + * dom(this).appendChild(instance.root); * // Changing a property on the instance will propagate to bindings * // in the template * instance.myProp = 'new value'; diff --git a/lib/mixins/dir-mixin.js b/lib/mixins/dir-mixin.js index a7a2c6b685..0e6d31e34f 100644 --- a/lib/mixins/dir-mixin.js +++ b/lib/mixins/dir-mixin.js @@ -56,24 +56,27 @@ function takeRecords() { } /** - * Element class mixin that allows elements to use the `:dir` CSS Selector to have - * text direction specific styling. + * Element class mixin that allows elements to use the `:dir` CSS Selector to + * have text direction specific styling. * - * With this mixin, any stylesheet provided in the template will transform `:dir` into - * `:host([dir])` and sync direction with the page via the element's `dir` attribute. + * With this mixin, any stylesheet provided in the template will transform + * `:dir` into `:host([dir])` and sync direction with the page via the + * element's `dir` attribute. * - * Elements can opt out of the global page text direction by setting the `dir` attribute - * directly in `ready()` or in HTML. + * Elements can opt out of the global page text direction by setting the `dir` + * attribute directly in `ready()` or in HTML. * * Caveats: - * - Applications must set `` or `` to sync direction - * - Automatic left-to-right or right-to-left styling is sync'd with the `` element only. + * - Applications must set `` or `` to sync + * direction + * - Automatic left-to-right or right-to-left styling is sync'd with the + * `` element only. * - Changing `dir` at runtime is supported. * - Opting out of the global direction styling is permanent * * @mixinFunction * @polymer - * @appliesMixin Polymer.PropertyAccessors + * @appliesMixin PropertyAccessors */ export const DirMixin = dedupingMixin((base) => { diff --git a/lib/mixins/disable-upgrade-mixin.js b/lib/mixins/disable-upgrade-mixin.js index 4110954dfd..3d008e836c 100644 --- a/lib/mixins/disable-upgrade-mixin.js +++ b/lib/mixins/disable-upgrade-mixin.js @@ -16,13 +16,13 @@ const DISABLED_ATTR = 'disable-upgrade'; /** * Element class mixin that allows the element to boot up in a non-enabled * state when the `disable-upgrade` attribute is present. This mixin is - * designed to be used with element classes like Polymer.Element that perform + * designed to be used with element classes like PolymerElement that perform * initial startup work when they are first connected. When the * `disable-upgrade` attribute is removed, if the element is connected, it * boots up and "enables" as it otherwise would; if it is not connected, the * element boots up when it is next connected. * - * Using `disable-upgrade` with Polymer.Element prevents any data propagation + * Using `disable-upgrade` with PolymerElement prevents any data propagation * to the element, any element DOM from stamping, or any work done in * connected/disconnctedCallback from occuring, but it does not prevent work * done in the element constructor. @@ -31,11 +31,11 @@ const DISABLED_ATTR = 'disable-upgrade'; * itself implements a `connectedCallback` so that it can control the work * done in `connectedCallback`. For example, * - * MyClass = Polymer.DisableUpgradeMixin(class extends BaseClass {...}); + * MyClass = DisableUpgradeMixin(class extends BaseClass {...}); * * @mixinFunction * @polymer - * @appliesMixin Polymer.ElementMixin + * @appliesMixin ElementMixin */ export const DisableUpgradeMixin = dedupingMixin((base) => { diff --git a/lib/mixins/element-mixin.js b/lib/mixins/element-mixin.js index 069558786e..33773f9f03 100644 --- a/lib/mixins/element-mixin.js +++ b/lib/mixins/element-mixin.js @@ -75,9 +75,9 @@ import { PropertiesMixin } from './properties-mixin.js'; * * @mixinFunction * @polymer - * @appliesMixin Polymer.PropertyEffects - * @appliesMixin Polymer.PropertiesMixin - * @property rootPath {string} Set to the value of `Polymer.rootPath`, + * @appliesMixin PropertyEffects + * @appliesMixin PropertiesMixin + * @property rootPath {string} Set to the value of `rootPath`, * which defaults to the main document path * @property importPath {string} Set to the value of the class's static * `importPath` property, which defaults to the path of this element's @@ -357,7 +357,7 @@ export const ElementMixin = dedupingMixin(base => { * Note that when subclassing, if the super class overrode the default * implementation and the subclass would like to provide an alternate * template via a `dom-module`, it should override this getter and - * return `Polymer.DomModule.import(this.is, 'template')`. + * return `DomModule.import(this.is, 'template')`. * * If a subclass would like to modify the super class template, it should * clone it rather than modify it in place. If the getter does expensive @@ -398,7 +398,7 @@ export const ElementMixin = dedupingMixin(base => { * The `importPath` property is also set on element instances and can be * used to create bindings relative to the import path. * - * For elements defined in ES modules, users should implement + * For elements defined in ES modules, users should implement * `static get importMeta() { return import.meta; }`, and the default * implementation of `importPath` will return `import.meta.url`'s path. * For elements defined in HTML imports, this getter will return the path @@ -417,7 +417,7 @@ export const ElementMixin = dedupingMixin(base => { this._importPath = pathFromUrl(meta.url); } else { const module = DomModule && DomModule.import(/** @type {PolymerElementConstructor} */ (this).is); - this._importPath = (module && module.assetpath) || + this._importPath = (module && module.assetpath) || Object.getPrototypeOf(/** @type {PolymerElementConstructor}*/ (this).prototype).constructor.importPath; } } @@ -441,7 +441,7 @@ export const ElementMixin = dedupingMixin(base => { } /** - * Overrides the default `Polymer.PropertyAccessors` to ensure class + * Overrides the default `PropertyAccessors` to ensure class * metaprogramming related to property accessors and effects has * completed (calls `finalize`). * @@ -599,7 +599,7 @@ export const ElementMixin = dedupingMixin(base => { } else { throw new Error('ShadowDOM not available. ' + // TODO(sorvell): move to compile-time conditional when supported - 'Polymer.Element can create dom as children instead of in ' + + 'PolymerElement can create dom as children instead of in ' + 'ShadowDOM by setting `this.root = this;\` before \`ready\`.'); } } @@ -691,7 +691,7 @@ export let instanceCount = 0; /** * Array of Polymer element classes that have been finalized. - * @type {Array} + * @type {Array} */ export const registrations = []; @@ -700,7 +700,7 @@ export const registrations = []; * @this {this} * @private */ -export function _regLog(prototype) { +function _regLog(prototype) { console.log('[' + prototype.is + ']: registered'); } @@ -733,7 +733,7 @@ export function dumpRegistrations() { * object of properties where the keys are CSS properties, and the values * are strings. * - * Example: `Polymer.updateStyles({'--color': 'blue'})` + * Example: `updateStyles({'--color': 'blue'})` * * These properties are retained unless a value of `null` is set. * diff --git a/lib/mixins/gesture-event-listeners.js b/lib/mixins/gesture-event-listeners.js index 2208a8dcf2..af1bd0dde9 100644 --- a/lib/mixins/gesture-event-listeners.js +++ b/lib/mixins/gesture-event-listeners.js @@ -12,9 +12,6 @@ import '../utils/boot.js'; import { dedupingMixin } from '../utils/mixin.js'; import * as gestures$0 from '../utils/gestures.js'; -/** - * @const {Polymer.Gestures} - */ const gestures = gestures$0; /** @@ -22,13 +19,14 @@ const gestures = gestures$0; * gesture events to nodes. * * The API is designed to be compatible with override points implemented - * in `Polymer.TemplateStamp` such that declarative event listeners in + * in `TemplateStamp` such that declarative event listeners in * templates will support gesture events when this mixin is applied along with - * `Polymer.TemplateStamp`. + * `TemplateStamp`. * * @mixinFunction * @polymer - * @summary Element class mixin that provides API for adding Polymer's cross-platform + * @summary Element class mixin that provides API for adding Polymer's + * cross-platform * gesture events to nodes */ export const GestureEventListeners = dedupingMixin(superClass => { diff --git a/lib/mixins/mutable-data.js b/lib/mixins/mutable-data.js index 58655b8121..3c937b94e8 100644 --- a/lib/mixins/mutable-data.js +++ b/lib/mixins/mutable-data.js @@ -32,9 +32,9 @@ function mutablePropertyChange(inst, property, value, old, mutableData) { /** * Element class mixin to skip strict dirty-checking for objects and arrays * (always consider them to be "dirty"), for use on elements utilizing - * `Polymer.PropertyEffects` + * `PropertyEffects` * - * By default, `Polymer.PropertyEffects` performs strict dirty checking on + * By default, `PropertyEffects` performs strict dirty checking on * objects, which means that any deep modifications to an object or array will * not be propagated unless "immutable" data patterns are used (i.e. all object * references from the root to the mutation were changed). @@ -54,10 +54,10 @@ function mutablePropertyChange(inst, property, value, old, mutableData) { * mixin or otherwise skip strict dirty checking for objects/arrays. * Specifically, any elements in the binding tree between the source of a * mutation and the consumption of it must apply this mixin or enable the - * `Polymer.OptionalMutableData` mixin. + * `OptionalMutableData` mixin. * * In order to make the dirty check strategy configurable, see - * `Polymer.OptionalMutableData`. + * `OptionalMutableData`. * * Note, the performance characteristics of propagating large object graphs * will be worse as opposed to using strict dirty checking with immutable @@ -77,7 +77,7 @@ export const MutableData = dedupingMixin(superClass => { */ class MutableData extends superClass { /** - * Overrides `Polymer.PropertyEffects` to provide option for skipping + * Overrides `PropertyEffects` to provide option for skipping * strict equality checking for Objects and Arrays. * * This method pulls the value to dirty check against from the `__dataTemp` @@ -108,7 +108,7 @@ export const MutableData = dedupingMixin(superClass => { * dirty-checking for objects and arrays (always consider them to be * "dirty") by setting a `mutable-data` attribute on an element instance. * - * By default, `Polymer.PropertyEffects` performs strict dirty checking on + * By default, `PropertyEffects` performs strict dirty checking on * objects, which means that any deep modifications to an object or array will * not be propagated unless "immutable" data patterns are used (i.e. all object * references from the root to the mutation were changed). @@ -128,7 +128,7 @@ export const MutableData = dedupingMixin(superClass => { * mixin or otherwise skip strict dirty checking for objects/arrays. * Specifically, any elements in the binding tree between the source of a * mutation and the consumption of it must enable this mixin or apply the - * `Polymer.MutableData` mixin. + * `MutableData` mixin. * * While this mixin adds the ability to forgo Object/Array dirty checking, * the `mutableData` flag defaults to false and must be set on the instance. @@ -164,7 +164,7 @@ export const OptionalMutableData = dedupingMixin(superClass => { } /** - * Overrides `Polymer.PropertyEffects` to provide option for skipping + * Overrides `PropertyEffects` to provide option for skipping * strict equality checking for Objects and Arrays. * * When `this.mutableData` is true on this instance, this method diff --git a/lib/mixins/properties-mixin.js b/lib/mixins/properties-mixin.js index 912b3b55c9..8a18d0d474 100644 --- a/lib/mixins/properties-mixin.js +++ b/lib/mixins/properties-mixin.js @@ -43,7 +43,7 @@ function normalizeProperties(props) { * * @mixinFunction * @polymer - * @appliesMixin Polymer.PropertiesChanged + * @appliesMixin PropertiesChanged * @summary Mixin that provides a minimal starting point for using * the PropertiesChanged mixin by providing a declarative `properties` object. */ diff --git a/lib/mixins/property-accessors.js b/lib/mixins/property-accessors.js index 4bb6974d1f..c00e1b4f76 100644 --- a/lib/mixins/property-accessors.js +++ b/lib/mixins/property-accessors.js @@ -70,16 +70,16 @@ function saveAccessorValue(model, property) { * (batched) `_propertiesChanged` callback. * * For basic usage of this mixin: - * + * * - Declare attributes to observe via the standard `static get observedAttributes()`. Use - * `dash-case` attribute names to represent `camelCase` property names. + * `dash-case` attribute names to represent `camelCase` property names. * - Implement the `_propertiesChanged` callback on the class. - * - Call `MyClass.createPropertiesForAttributes()` **once** on the class to generate - * property accessors for each observed attribute. This must be called before the first + * - Call `MyClass.createPropertiesForAttributes()` **once** on the class to generate + * property accessors for each observed attribute. This must be called before the first * instance is created, for example, by calling it before calling `customElements.define`. * It can also be called lazily from the element's `constructor`, as long as it's guarded so * that the call is only made once, when the first instance is created. - * - Call `this._enableProperties()` in the element's `connectedCallback` to enable + * - Call `this._enableProperties()` in the element's `connectedCallback` to enable * the accessors. * * Any `observedAttributes` will automatically be @@ -88,7 +88,7 @@ function saveAccessorValue(model, property) { * * @mixinFunction * @polymer - * @appliesMixin Polymer.PropertiesChanged + * @appliesMixin PropertiesChanged * @summary Element class mixin for reacting to property changes from * generated property accessors. */ diff --git a/lib/mixins/property-effects.js b/lib/mixins/property-effects.js index 00f1e17c2a..91b5d12094 100644 --- a/lib/mixins/property-effects.js +++ b/lib/mixins/property-effects.js @@ -1105,8 +1105,8 @@ function upper(name) { * * @mixinFunction * @polymer - * @appliesMixin Polymer.TemplateStamp - * @appliesMixin Polymer.PropertyAccessors + * @appliesMixin TemplateStamp + * @appliesMixin PropertyAccessors * @summary Element class mixin that provides meta-programming for Polymer's * template binding and data observation system. */ @@ -1203,7 +1203,7 @@ export const PropertyEffects = dedupingMixin(superClass => { } /** - * Overrides `Polymer.PropertyAccessors` implementation to provide a + * Overrides `PropertyAccessors` implementation to provide a * more efficient implementation of initializing properties from * the prototype on the instance. * @@ -1218,7 +1218,7 @@ export const PropertyEffects = dedupingMixin(superClass => { } /** - * Overrides `Polymer.PropertyAccessors` implementation to avoid setting + * Overrides `PropertyAccessors` implementation to avoid setting * `_setProperty`'s `shouldNotify: true`. * * @override diff --git a/lib/mixins/strict-binding-parser.js b/lib/mixins/strict-binding-parser.js index 48f86847fd..6af6612f18 100644 --- a/lib/mixins/strict-binding-parser.js +++ b/lib/mixins/strict-binding-parser.js @@ -112,9 +112,8 @@ function storeMethodNumber(bindingData, text, i) { * handle more cases, with the potential performance hit. * * @mixinFunction - * @appliesMixin Polymer.PropertyEffects + * @appliesMixin PropertyEffects * @polymer - * @memberof Polymer * @summary Mixin that parses binding expressions and generates corresponding metadata. */ const StrictBindingParser = dedupingMixin((base) => { diff --git a/lib/utils/array-splice.js b/lib/utils/array-splice.js index 2ee70ff326..77ccb1af5c 100644 --- a/lib/utils/array-splice.js +++ b/lib/utils/array-splice.js @@ -258,22 +258,6 @@ function sharedSuffix(current, old, searchLength) { return count; } -function calculateSplices(current, previous) { - return calcSplices(current, 0, current.length, previous, 0, - previous.length); -} - -function equals(currentValue, previousValue) { - return currentValue === previousValue; -} - -/** - * @summary Module that provides utilities for diffing arrays. - */ -`TODO(modulizer): A namespace named Polymer.ArraySplice was -declared here. The surrounding comments should be reviewed, -and this string can then be deleted`; - /** * Returns an array of splice records indicating the minimum edits required * to transform the `previous` array into the `current` array. @@ -305,4 +289,11 @@ and this string can then be deleted`; * the array of removed items from this location; `addedCount` the number * of items added at this location. */ -export { calculateSplices }; +export function calculateSplices(current, previous) { + return calcSplices(current, 0, current.length, previous, 0, + previous.length); +} + +function equals(currentValue, previousValue) { + return currentValue === previousValue; +} diff --git a/lib/utils/async.js b/lib/utils/async.js index ce9ee1023b..e332f95325 100644 --- a/lib/utils/async.js +++ b/lib/utils/async.js @@ -7,6 +7,19 @@ The complete set of contributors may be found at http://polymer.github.io/CONTRI 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 */ + +/** + * @fileoverview + * + * This module provides a number of strategies for enqueuing asynchronous + * tasks. Each sub-module provides a standard `run(fn)` interface that returns a + * handle, and a `cancel(handle)` interface for canceling async tasks before + * they run. + * + * @summary Module that provides a number of strategies for enqueuing + * asynchronous tasks. + */ + import './boot.js'; // Microtask implemented using Mutation Observer @@ -33,30 +46,18 @@ function microtaskFlush() { microtaskLastHandle += len; } -/** - * Module that provides a number of strategies for enqueuing asynchronous - * tasks. Each sub-module provides a standard `run(fn)` interface that returns a - * handle, and a `cancel(handle)` interface for canceling async tasks before - * they run. - * - * @summary Module that provides a number of strategies for enqueuing asynchronous - * tasks. - */ -`TODO(modulizer): A namespace named Polymer.Async was -declared here. The surrounding comments should be reviewed, -and this string can then be deleted`; - /** * Async interface wrapper around `setTimeout`. * + * @namespace * @summary Async interface wrapper around `setTimeout`. */ -export const timeOut = { +const timeOut = { /** * Returns a sub-module with the async interface providing the provided * delay. * - * @memberof Polymer.Async.timeOut + * @memberof timeOut * @param {number=} delay Time to wait before calling callbacks in ms * @return {!AsyncInterface} An async timeout interface */ @@ -71,7 +72,7 @@ export const timeOut = { /** * Enqueues a function called in the next task. * - * @memberof Polymer.Async.timeOut + * @memberof timeOut * @param {!Function} fn Callback to run * @param {number=} delay Delay in milliseconds * @return {number} Handle used for canceling task @@ -82,7 +83,7 @@ export const timeOut = { /** * Cancels a previously enqueued `timeOut` callback. * - * @memberof Polymer.Async.timeOut + * @memberof timeOut * @param {number} handle Handle returned from `run` of callback to cancel * @return {void} */ @@ -90,17 +91,19 @@ export const timeOut = { window.clearTimeout(handle); } }; +export {timeOut}; /** * Async interface wrapper around `requestAnimationFrame`. * + * @namespace * @summary Async interface wrapper around `requestAnimationFrame`. */ -export const animationFrame = { +const animationFrame = { /** * Enqueues a function called at `requestAnimationFrame` timing. * - * @memberof Polymer.Async.animationFrame + * @memberof animationFrame * @param {function(number):void} fn Callback to run * @return {number} Handle used for canceling task */ @@ -110,7 +113,7 @@ export const animationFrame = { /** * Cancels a previously enqueued `animationFrame` callback. * - * @memberof Polymer.Async.animationFrame + * @memberof animationFrame * @param {number} handle Handle returned from `run` of callback to cancel * @return {void} */ @@ -118,18 +121,20 @@ export const animationFrame = { window.cancelAnimationFrame(handle); } }; +export {animationFrame}; /** * Async interface wrapper around `requestIdleCallback`. Falls back to * `setTimeout` on browsers that do not support `requestIdleCallback`. * + * @namespace * @summary Async interface wrapper around `requestIdleCallback`. */ -export const idlePeriod = { +const idlePeriod = { /** * Enqueues a function called at `requestIdleCallback` timing. * - * @memberof Polymer.Async.idlePeriod + * @memberof idlePeriod * @param {function(!IdleDeadline):void} fn Callback to run * @return {number} Handle used for canceling task */ @@ -141,7 +146,7 @@ export const idlePeriod = { /** * Cancels a previously enqueued `idlePeriod` callback. * - * @memberof Polymer.Async.idlePeriod + * @memberof idlePeriod * @param {number} handle Handle returned from `run` of callback to cancel * @return {void} */ @@ -151,6 +156,7 @@ export const idlePeriod = { window.clearTimeout(handle); } }; +export {idlePeriod}; /** * Async interface for enqueuing callbacks that run at microtask timing. @@ -161,15 +167,16 @@ export const idlePeriod = { * Promises are avoided as an implementation choice for the time being * due to Safari bugs that cause Promises to lack microtask guarantees. * + * @namespace * @summary Async interface for enqueuing callbacks that run at microtask * timing. */ -export const microTask = { +const microTask = { /** * Enqueues a function called at microtask timing. * - * @memberof Polymer.Async.microTask + * @memberof microTask * @param {!Function=} callback Callback to run * @return {number} Handle used for canceling task */ @@ -182,7 +189,7 @@ export const microTask = { /** * Cancels a previously enqueued `microTask` callback. * - * @memberof Polymer.Async.microTask + * @memberof microTask * @param {number} handle Handle returned from `run` of callback to cancel * @return {void} */ @@ -197,3 +204,4 @@ export const microTask = { } }; +export {microTask}; diff --git a/lib/utils/boot.js b/lib/utils/boot.js index 701ee1e259..8553f14e8f 100644 --- a/lib/utils/boot.js +++ b/lib/utils/boot.js @@ -9,6 +9,3 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN */ window.JSCompiler_renameProperty = function(prop, obj) { return prop; } - -/** @namespace Polymer */ -let __PolymerBootstrap; diff --git a/lib/utils/debounce.js b/lib/utils/debounce.js index 8804283de5..e40eaddc5a 100644 --- a/lib/utils/debounce.js +++ b/lib/utils/debounce.js @@ -14,9 +14,8 @@ import './async.js'; /** * @summary Collapse multiple callbacks into one invocation after a timer. - * @memberof Polymer */ -class Debouncer { +export const Debouncer = class Debouncer { constructor() { this._asyncModule = null; this._callback = null; @@ -76,22 +75,26 @@ class Debouncer { * microtask and "debounced" such that the provided callback function is * called once. Add this method to a custom element: * + * ```js + * import {microtask} from '@polymer/polymer/lib/utils/async.js'; + * import {Debouncer} from '@polymer/polymer/lib/utils/debounce.js'; + * // ... + * * _debounceWork() { - * this._debounceJob = Polymer.Debouncer.debounce(this._debounceJob, - * Polymer.Async.microTask, () => { - * this._doWork(); - * }); + * this._debounceJob = Debouncer.debounce(this._debounceJob, + * microTask, () => this._doWork()); * } + * ``` * * If the `_debounceWork` method is called multiple times within the same * microtask, the `_doWork` function will be called only once at the next * microtask checkpoint. * * Note: In testing it is often convenient to avoid asynchrony. To accomplish - * this with a debouncer, you can use `Polymer.enqueueDebouncer` and - * `Polymer.flush`. For example, extend the above example by adding - * `Polymer.enqueueDebouncer(this._debounceJob)` at the end of the - * `_debounceWork` method. Then in a test, call `Polymer.flush` to ensure + * this with a debouncer, you can use `enqueueDebouncer` and + * `flush`. For example, extend the above example by adding + * `enqueueDebouncer(this._debounceJob)` at the end of the + * `_debounceWork` method. Then in a test, call `flush` to ensure * the debouncer has completed. * * @param {Debouncer?} debouncer Debouncer object. @@ -109,6 +112,3 @@ class Debouncer { return debouncer; } } - -/** @const */ -export { Debouncer }; diff --git a/lib/utils/flattened-nodes-observer.js b/lib/utils/flattened-nodes-observer.js index d24dd189f6..7d522dc45c 100644 --- a/lib/utils/flattened-nodes-observer.js +++ b/lib/utils/flattened-nodes-observer.js @@ -44,11 +44,11 @@ function isSlot(node) { * * An example: * ```js - * class TestSelfObserve extends Polymer.Element { + * class TestSelfObserve extends PolymerElement { * static get is() { return 'test-self-observe';} * connectedCallback() { * super.connectedCallback(); - * this._observer = new Polymer.FlattenedNodesObserver(this, (info) => { + * this._observer = new FlattenedNodesObserver(this, (info) => { * this.info = info; * }); * } @@ -60,11 +60,10 @@ function isSlot(node) { * customElements.define(TestSelfObserve.is, TestSelfObserve); * ``` * - * @memberof Polymer * @summary Class that listens for changes (additions or removals) to * "flattened nodes" on a given `node`. */ -class FlattenedNodesObserver { +export class FlattenedNodesObserver { /** * Returns the list of flattened nodes for the given `node`. @@ -303,5 +302,3 @@ class FlattenedNodesObserver { } } - -export { FlattenedNodesObserver }; diff --git a/lib/utils/flush.js b/lib/utils/flush.js index e73521d885..874eb0e55a 100644 --- a/lib/utils/flush.js +++ b/lib/utils/flush.js @@ -12,9 +12,9 @@ import './boot.js'; let debouncerQueue = []; /** - * Adds a `Polymer.Debouncer` to a list of globally flushable tasks. + * Adds a `Debouncer` to a list of globally flushable tasks. * - * @param {!Polymer.Debouncer} debouncer Debouncer to enqueue + * @param {!Debouncer} debouncer Debouncer to enqueue * @return {void} */ export const enqueueDebouncer = function(debouncer) { diff --git a/lib/utils/gestures.js b/lib/utils/gestures.js index a883b8983c..601409defa 100644 --- a/lib/utils/gestures.js +++ b/lib/utils/gestures.js @@ -57,10 +57,12 @@ let SUPPORTS_PASSIVE = false; })(); /** - * Generate settings for event listeners, dependant on `Polymer.passiveTouchGestures` + * Generate settings for event listeners, dependant on `passiveTouchGestures` * - * @param {string} eventName Event name to determine if `{passive}` option is needed - * @return {{passive: boolean} | undefined} Options to use for addEventListener and removeEventListener + * @param {string} eventName Event name to determine if `{passive}` option is + * needed + * @return {{passive: boolean} | undefined} Options to use for addEventListener + * and removeEventListener */ function PASSIVE_TOUCH(eventName) { if (isMouseEvent(eventName) || eventName === 'touchend') { @@ -378,7 +380,7 @@ export function deepTargetFind(x, y) { * @param {Event} ev Event. * @return {EventTarget} Returns the event target. */ -export function _findOriginalTarget(ev) { +function _findOriginalTarget(ev) { // shadowdom if (ev.composedPath) { const targets = /** @type {!Array} */(ev.composedPath()); @@ -394,7 +396,7 @@ export function _findOriginalTarget(ev) { * @param {Event} ev Event. * @return {void} */ -export function _handleNative(ev) { +function _handleNative(ev) { let handled; let type = ev.type; let node = ev.currentTarget; @@ -456,7 +458,7 @@ export function _handleNative(ev) { * @param {TouchEvent} ev Event. * @return {void} */ -export function _handleTouchAction(ev) { +function _handleTouchAction(ev) { let t = ev.changedTouches[0]; let type = ev.type; if (type === 'touchstart') { @@ -534,7 +536,7 @@ export function removeListener(node, evType, handler) { * @return {void} * @this {Gestures} */ -export function _add(node, evType, handler) { +function _add(node, evType, handler) { let recognizer = gestures[evType]; let deps = recognizer.deps; let name = recognizer.name; @@ -574,7 +576,7 @@ export function _add(node, evType, handler) { * @return {void} * @this {Gestures} */ -export function _remove(node, evType, handler) { +function _remove(node, evType, handler) { let recognizer = gestures[evType]; let deps = recognizer.deps; let name = recognizer.name; @@ -616,7 +618,7 @@ export function register(recog) { * @return {Object} Returns the gesture for the given event name. * @this {Gestures} */ -export function _findRecognizerByEvent(evName) { +function _findRecognizerByEvent(evName) { for (let i = 0, r; i < recognizers.length; i++) { r = recognizers[i]; for (let j = 0, n; j < r.emits.length; j++) { @@ -661,7 +663,7 @@ export function setTouchAction(node, value) { * @param {!Object=} detail The detail object to populate on the event. * @return {void} */ -export function _fire(target, type, detail) { +function _fire(target, type, detail) { let ev = new Event(type, { bubbles: true, cancelable: true, composed: true }); ev.detail = detail; target.dispatchEvent(ev); diff --git a/lib/utils/html-tag.js b/lib/utils/html-tag.js index a88ac89948..d5640629b9 100644 --- a/lib/utils/html-tag.js +++ b/lib/utils/html-tag.js @@ -35,7 +35,9 @@ function literalValue(value) { if (value instanceof LiteralString) { return /** @type {!LiteralString} */(value).value; } else { - throw new Error(`non-literal value passed to Polymer.htmlLiteral: ${value}`); + throw new Error( + `non-literal value passed to Polymer's htmlLiteral function: ${value}` + ); } } @@ -49,7 +51,8 @@ function htmlValue(value) { } else if (value instanceof LiteralString) { return literalValue(value); } else { - throw new Error(`non-template value passed to Polymer.html: ${value}`); + throw new Error( + `non-template value passed to Polymer's html function: ${value}`); } } @@ -62,12 +65,12 @@ function htmlValue(value) { * Templates can be composed by interpolating `HTMLTemplateElement`s in * expressions in the JavaScript template literal. The nested template's * `innerHTML` is included in the containing template. The only other - * values allowed in expressions are those returned from `Polymer.htmlLiteral` + * values allowed in expressions are those returned from `htmlLiteral` * which ensures only literal values from JS source ever reach the HTML, to * guard against XSS risks. * * All other values are disallowed in expressions to help prevent XSS - * attacks; however, `Polymer.htmlLiteral` can be used to compose static + * attacks; however, `htmlLiteral` can be used to compose static * string values into templates. This is useful to compose strings into * places that do not accept html, like the css text of a `style` * element. @@ -75,13 +78,13 @@ function htmlValue(value) { * Example: * * static get template() { - * return Polymer.html` + * return html` * *
${this.partialTemplate}
* ${super.template} * `; * } - * static get partialTemplate() { return Polymer.html`Partial!`; } + * static get partialTemplate() { return html`Partial!`; } * * @param {!ITemplateArray} strings Constant parts of tagged template literal * @param {...*} values Variable parts of tagged template literal @@ -95,22 +98,24 @@ export const html = function html(strings, ...values) { }; /** - * An html literal tag that can be used with `Polymer.html` to compose. + * An html literal tag that can be used with `html` to compose. * a literal string. * * Example: * * static get template() { - * return Polymer.html` + * return html` * *
${staticValue}
* ${super.template} * `; * } - * static get styleTemplate() { return Polymer.htmlLiteral`.shadowed { background: gray; }`; } + * static get styleTemplate() { + * return htmlLiteral`.shadowed { background: gray; }`; + * } * * @param {!ITemplateArray} strings Constant parts of tagged template literal * @param {...*} values Variable parts of tagged template literal diff --git a/lib/utils/path.js b/lib/utils/path.js index 3b473850ce..79292692ac 100644 --- a/lib/utils/path.js +++ b/lib/utils/path.js @@ -24,8 +24,8 @@ and this string can then be deleted`; * Example: * * ``` - * Polymer.Path.isPath('foo.bar.baz') // true - * Polymer.Path.isPath('foo') // false + * isPath('foo.bar.baz') // true + * isPath('foo') // false * ``` * * @param {string} path Path string @@ -41,8 +41,8 @@ export function isPath(path) { * Example: * * ``` - * Polymer.Path.root('foo.bar.baz') // 'foo' - * Polymer.Path.root('foo') // 'foo' + * root('foo.bar.baz') // 'foo' + * root('foo') // 'foo' * ``` * * @param {string} path Path string @@ -63,9 +63,9 @@ export function root(path) { * Example: * * ``` - * Polymer.Path.isAncestor('foo.bar', 'foo') // true - * Polymer.Path.isAncestor('foo.bar', 'foo.bar') // false - * Polymer.Path.isAncestor('foo.bar', 'foo.bar.baz') // false + * isAncestor('foo.bar', 'foo') // true + * isAncestor('foo.bar', 'foo.bar') // false + * isAncestor('foo.bar', 'foo.bar.baz') // false * ``` * * @param {string} base Path string to test against. @@ -83,9 +83,9 @@ export function isAncestor(base, path) { * Example: * * ``` - * Polymer.Path.isDescendant('foo.bar', 'foo.bar.baz') // true - * Polymer.Path.isDescendant('foo.bar', 'foo.bar') // false - * Polymer.Path.isDescendant('foo.bar', 'foo') // false + * isDescendant('foo.bar', 'foo.bar.baz') // true + * isDescendant('foo.bar', 'foo.bar') // false + * isDescendant('foo.bar', 'foo') // false * ``` * * @param {string} base Path string to test against. @@ -106,7 +106,7 @@ export function isDescendant(base, path) { * Example: * * ``` - * Polymer.Path.translate('foo.bar', 'zot', 'foo.bar.baz') // 'zot.baz' + * translate('foo.bar', 'zot', 'foo.bar.baz') // 'zot.baz' * ``` * * @param {string} base Current base string to remove @@ -137,8 +137,8 @@ export function matches(base, path) { * Example: * * ``` - * Polymer.Path.normalize(['foo.bar', 0, 'baz']) // 'foo.bar.0.baz' - * Polymer.Path.normalize('foo.bar.0.baz') // 'foo.bar.0.baz' + * normalize(['foo.bar', 0, 'baz']) // 'foo.bar.0.baz' + * normalize('foo.bar.0.baz') // 'foo.bar.0.baz' * ``` * * @param {string | !Array} path Input path @@ -166,8 +166,8 @@ export function normalize(path) { * Example: * * ``` - * Polymer.Path.split(['foo.bar', 0, 'baz']) // ['foo', 'bar', '0', 'baz'] - * Polymer.Path.split('foo.bar.0.baz') // ['foo', 'bar', '0', 'baz'] + * split(['foo.bar', 0, 'baz']) // ['foo', 'bar', '0', 'baz'] + * split('foo.bar.0.baz') // ['foo', 'bar', '0', 'baz'] * ``` * * @param {string | !Array} path Input path @@ -246,13 +246,13 @@ export function set(root, path, value) { /** * Returns true if the given string is a structured data path (has dots). * - * This function is deprecated. Use `Polymer.Path.isPath` instead. + * This function is deprecated. Use `isPath` instead. * * Example: * * ``` - * Polymer.Path.isDeep('foo.bar.baz') // true - * Polymer.Path.isDeep('foo') // false + * isDeep('foo.bar.baz') // true + * isDeep('foo') // false * ``` * * @deprecated diff --git a/lib/utils/render-status.js b/lib/utils/render-status.js index cbe65c9a41..1db3dd9ad4 100644 --- a/lib/utils/render-status.js +++ b/lib/utils/render-status.js @@ -76,7 +76,7 @@ and this string can then be deleted`; * since measurement may not be reliable in custom element callbacks before * the first render, as well as for batching measurement tasks in general. * - * Tasks in this queue may be flushed by calling `Polymer.RenderStatus.flush()`. + * Tasks in this queue may be flushed by calling `flush()`. * * @param {*} context Context object the callback function will be bound to * @param {function(...*):void} callback Callback function diff --git a/lib/utils/resolve-url.js b/lib/utils/resolve-url.js index 934b962b9f..06b2292e12 100644 --- a/lib/utils/resolve-url.js +++ b/lib/utils/resolve-url.js @@ -15,17 +15,16 @@ let workingURL; let resolveDoc; /** * Resolves the given URL against the provided `baseUri'. - * + * * Note that this function performs no resolution for URLs that start * with `/` (absolute URLs) or `#` (hash identifiers). For general purpose * URL resolution, use `window.URL`. * - * @memberof Polymer.ResolveUrl * @param {string} url Input URL to resolve * @param {?string=} baseURI Base URI to resolve the URL against * @return {string} resolved URL */ -function resolveUrl(url, baseURI) { +export function resolveUrl(url, baseURI) { if (url && ABS_URL.test(url)) { return url; } @@ -64,12 +63,11 @@ function resolveUrl(url, baseURI) { * Resolves any relative URL's in the given CSS text against the provided * `ownerDocument`'s `baseURI`. * - * @memberof Polymer.ResolveUrl * @param {string} cssText CSS text to process * @param {string} baseURI Base URI to resolve the URL against * @return {string} Processed CSS text with resolved URL's */ -function resolveCss(cssText, baseURI) { +export function resolveCss(cssText, baseURI) { return cssText.replace(CSS_URL_RX, function(m, pre, url, post) { return pre + '\'' + resolveUrl(url.replace(/["']/g, ''), baseURI) + @@ -81,23 +79,9 @@ function resolveCss(cssText, baseURI) { * Returns a path from a given `url`. The path includes the trailing * `/` from the url. * - * @memberof Polymer.ResolveUrl * @param {string} url Input URL to transform * @return {string} resolved path */ -function pathFromUrl(url) { +export function pathFromUrl(url) { return url.substring(0, url.lastIndexOf('/') + 1); } - -/** - * Module with utilities for resolving relative URL's. - * - * @summary Module with utilities for resolving relative URL's. - */ -`TODO(modulizer): A namespace named Polymer.ResolveUrl was -declared here. The surrounding comments should be reviewed, -and this string can then be deleted`; - -export { resolveCss }; -export { resolveUrl }; -export { pathFromUrl }; diff --git a/lib/utils/settings.js b/lib/utils/settings.js index f93d34f22c..461bd33b4b 100644 --- a/lib/utils/settings.js +++ b/lib/utils/settings.js @@ -17,22 +17,18 @@ export const useNativeCustomElements = !(window.customElements.polyfillWrapFlush /** * Globally settable property that is automatically assigned to - * `Polymer.ElementMixin` instances, useful for binding in templates to + * `ElementMixin` instances, useful for binding in templates to * make URL's relative to an application's root. Defaults to the main * document URL, but can be overridden by users. It may be useful to set - * `Polymer.rootPath` to provide a stable application mount path when + * `rootPath` to provide a stable application mount path when * using client side routing. - * - * @memberof Polymer */ -let rootPath = undefined || +export let rootPath = undefined || pathFromUrl(document.baseURI || window.location.href); -export { rootPath }; - /** - * Sets the global rootPath property used by `Polymer.ElementMixin` and - * available via `Polymer.rootPath`. + * Sets the global rootPath property used by `ElementMixin` and + * available via `rootPath`. * * @param {string} path The new root path * @return {void} @@ -56,15 +52,12 @@ export const setRootPath = function(path) { * `node` is the node where the value is being inserted. * * @type {(function(*,string,string,Node):*)|undefined} - * @memberof Polymer */ -let sanitizeDOMValue = undefined; - -// This is needed for tooling -export { sanitizeDOMValue }; +export let sanitizeDOMValue = undefined; /** - * Sets the global sanitizeDOMValue available via `Polymer.sanitizeDOMValue`. + * Sets the global sanitizeDOMValue available via this module's exported + * `sanitizeDOMValue` variable. * * @param {(function(*,string,string,Node):*)|undefined} newSanitizeDOMValue the global sanitizeDOMValue callback * @return {void} @@ -78,12 +71,8 @@ export const setSanitizeDOMValue = function(newSanitizeDOMValue) { * When set to `true`, gestures made from touch will not be able to prevent scrolling, allowing for smoother * scrolling performance. * Defaults to `false` for backwards compatibility. - * - * @memberof Polymer */ -let passiveTouchGestures = false; - -export { passiveTouchGestures }; +export let passiveTouchGestures = false; /** * Sets `passiveTouchGestures` globally for all elements using Polymer Gestures. diff --git a/lib/utils/style-gather.js b/lib/utils/style-gather.js index 6479fb6672..5daadb1601 100644 --- a/lib/utils/style-gather.js +++ b/lib/utils/style-gather.js @@ -14,7 +14,7 @@ const INCLUDE_ATTR = 'include'; const SHADY_UNSCOPED_ATTR = 'shady-unscoped'; function importModule(moduleId) { - const /** Polymer.DomModule */ PolymerDomModule = customElements.get('dom-module'); + const /** DomModule */ PolymerDomModule = customElements.get('dom-module'); if (!PolymerDomModule) { return null; } @@ -49,6 +49,7 @@ and this string can then be deleted`; /** * Returns a list of