diff --git a/lib/elements/dom-bind.js b/lib/elements/dom-bind.js index b541cb2f3e..9613ab9e3e 100644 --- a/lib/elements/dom-bind.js +++ b/lib/elements/dom-bind.js @@ -60,19 +60,28 @@ export class DomBind extends domBindBase { this.__children = null; } - /** @return {void} */ + /** + * @override + * @return {void} + */ attributeChangedCallback() { // assumes only one observed attribute this.mutableData = true; } - /** @return {void} */ + /** + * @override + * @return {void} + */ connectedCallback() { this.style.display = 'none'; this.render(); } - /** @return {void} */ + /** + * @override + * @return {void} + */ disconnectedCallback() { this.__removeChildren(); } @@ -112,7 +121,8 @@ export class DomBind extends domBindBase { observer.observe(this, {childList: true}); return; } - this.root = this._stampTemplate(template); + this.root = this._stampTemplate( + /** @type {!HTMLTemplateElement} */(template)); this.$ = this.root.$; this.__children = []; for (let n=this.root.firstChild; n; n=n.nextSibling) { diff --git a/lib/elements/dom-if.js b/lib/elements/dom-if.js index d130425556..52b6a10d84 100644 --- a/lib/elements/dom-if.js +++ b/lib/elements/dom-if.js @@ -87,6 +87,7 @@ export class DomIf extends PolymerElement { this.__instance = null; this._lastIf = false; this.__ctor = null; + this.__hideTemplateChildren__ = false; } __debounceRender() { @@ -114,6 +115,7 @@ export class DomIf extends PolymerElement { } /** + * @override * @return {void} */ disconnectedCallback() { @@ -126,6 +128,7 @@ export class DomIf extends PolymerElement { } /** + * @override * @return {void} */ connectedCallback() { @@ -196,7 +199,7 @@ export class DomIf extends PolymerElement { /** * @param {string} prop Property to forward * @param {*} value Value of property - * @this {this} + * @this {DomIf} */ forwardHostProp: function(prop, value) { if (this.__instance) { @@ -270,6 +273,7 @@ export class DomIf extends PolymerElement { * "shown." * @return {void} * @protected + * @suppress {visibility} */ _showHideChildren() { let hidden = this.__hideTemplateChildren__ || !this.if; diff --git a/lib/elements/dom-repeat.js b/lib/elements/dom-repeat.js index 892fed745c..0f07443292 100644 --- a/lib/elements/dom-repeat.js +++ b/lib/elements/dom-repeat.js @@ -295,12 +295,14 @@ export class DomRepeat extends domRepeatBase { this.__sortFn = null; this.__filterFn = null; this.__observePaths = null; + /** @type {?function(new:Polymer.TemplateInstanceBase, *)} */ this.__ctor = null; this.__isDetached = true; this.template = null; } /** + * @override * @return {void} */ disconnectedCallback() { @@ -312,6 +314,7 @@ export class DomRepeat extends domRepeatBase { } /** + * @override * @return {void} */ connectedCallback() { @@ -356,7 +359,7 @@ export class DomRepeat extends domRepeatBase { parentModel: true, instanceProps: instanceProps, /** - * @this {this} + * @this {DomRepeat} * @param {string} prop Property to set * @param {*} value Value to set property to */ @@ -367,7 +370,7 @@ export class DomRepeat extends domRepeatBase { } }, /** - * @this {this} + * @this {DomRepeat} * @param {Object} inst Instance to notify * @param {string} prop Property to notify * @param {*} value Value to notify diff --git a/lib/legacy/polymer.dom.js b/lib/legacy/polymer.dom.js index ec79419604..ff5d33b41f 100644 --- a/lib/legacy/polymer.dom.js +++ b/lib/legacy/polymer.dom.js @@ -11,7 +11,10 @@ import '../utils/boot.js'; import '../utils/settings.js'; import { FlattenedNodesObserver } from '../utils/flattened-nodes-observer.js'; -import { flush as flush$0, enqueueDebouncer } from '../utils/flush.js'; +export { flush, enqueueDebouncer as addDebouncer } from '../utils/flush.js'; +/* eslint-disable no-unused-vars */ +import { Debouncer } from '../utils/debounce.js'; // used in type annotations +/* eslint-enable no-unused-vars */ const p = Element.prototype; /** @@ -48,15 +51,16 @@ export class DomApi { } /** - * Returns an instance of `Polymer.FlattenedNodesObserver` that + * Returns an instance of `FlattenedNodesObserver` that * listens for node changes on this element. * - * @param {function(!Element, { target: !Element, addedNodes: !Array, removedNodes: !Array }):void} callback Called when direct or distributed children + * @param {function(this:Element, { target: !Element, addedNodes: !Array, removedNodes: !Array }):void} callback Called when direct or distributed children * of this element changes * @return {!FlattenedNodesObserver} Observer instance */ observeNodes(callback) { - return new FlattenedNodesObserver(this.node, callback); + return new FlattenedNodesObserver( + /** @type {!Element} */(this.node), callback); } /** @@ -157,7 +161,8 @@ export class DomApi { * nodes assigned to child slots. */ getEffectiveChildNodes() { - return FlattenedNodesObserver.getFlattenedNodes(this.node); + return FlattenedNodesObserver.getFlattenedNodes( + /** @type {!HTMLElement} */ (this.node)); } /** @@ -219,12 +224,19 @@ function forwardProperties(proto, properties) { for (let i=0; i < properties.length; i++) { let name = properties[i]; Object.defineProperty(proto, name, { + /** + * @this {DomApi} + * @return {*} . + */ get: function() { - const domApi = /** @type {DomApi} */(this); - return domApi.node[name]; + return this.node[name]; }, + /** + * @this {DomApi} + * @param {*} value . + */ set: function(value) { - /** @type {DomApi} */ (this).node[name] = value; + this.node[name] = value; }, configurable: true }); @@ -233,7 +245,7 @@ function forwardProperties(proto, properties) { /** - * Event API wrapper class returned from `Polymer.dom.(target)` when + * Event API wrapper class returned from `dom.(target)` when * `target` is an `Event`. */ class EventApi { @@ -400,22 +412,3 @@ export const dom = function(obj) { } return obj.__domApi; }; - -/** - * Forces several classes of asynchronously queued tasks to flush: - * - Debouncers added via `Polymer.enqueueDebouncer` - * - ShadyDOM distribution - * - * This method facades to `Polymer.flush`. - * - */ -export { flush$0 as flush }; - -/** - * Adds a `Polymer.Debouncer` to a list of globally flushable tasks. - * - * This method facades to `Polymer.enqueueDebouncer`. - * - * @param {!Polymer.Debouncer} debouncer Debouncer to enqueue - */ -export { enqueueDebouncer as addDebouncer }; diff --git a/lib/utils/debounce.js b/lib/utils/debounce.js index 5215cc27c1..ba41f61aec 100644 --- a/lib/utils/debounce.js +++ b/lib/utils/debounce.js @@ -45,7 +45,7 @@ export class Debouncer { */ cancel() { if (this.isActive()) { - this._asyncModule.cancel(this._timer); + this._asyncModule.cancel(/** @type {number} */(this._timer)); this._timer = null; } } @@ -76,7 +76,7 @@ export class Debouncer { * called once. Add this method to a custom element: * * ```js - * import {microTask} from '@polymer/polymer/lib/utils/async.js'; + * import {microtask} from '@polymer/polymer/lib/utils/async.js'; * import {Debouncer} from '@polymer/polymer/lib/utils/debounce.js'; * // ... * diff --git a/lib/utils/flattened-nodes-observer.js b/lib/utils/flattened-nodes-observer.js index 027a1837da..87802d5335 100644 --- a/lib/utils/flattened-nodes-observer.js +++ b/lib/utils/flattened-nodes-observer.js @@ -14,7 +14,7 @@ import { microTask } from './async.js'; /** * Returns true if `node` is a slot element - * @param {Node} node Node to test. + * @param {!Node} node Node to test. * @return {boolean} Returns true if the given `node` is a slot * @private */ @@ -74,18 +74,19 @@ export class FlattenedNodesObserver { * nodes list is `
`. If the `` has other * `` elements assigned to it, these are flattened as well. * - * @param {HTMLElement|HTMLSlotElement} node The node for which to return the list of flattened nodes. - * @return {Array} The list of flattened nodes for the given `node`. + * @param {!HTMLElement|!HTMLSlotElement} node The node for which to + * return the list of flattened nodes. + * @return {!Array} The list of flattened nodes for the given `node`. * @nocollapse See https://github.com/google/closure-compiler/issues/2763 */ static getFlattenedNodes(node) { if (isSlot(node)) { - node = /** @type {HTMLSlotElement} */(node); // eslint-disable-line no-self-assign + node = /** @type {!HTMLSlotElement} */(node); // eslint-disable-line no-self-assign return node.assignedNodes({flatten: true}); } else { return Array.from(node.childNodes).map((node) => { if (isSlot(node)) { - node = /** @type {HTMLSlotElement} */(node); // eslint-disable-line no-self-assign + node = /** @type {!HTMLSlotElement} */(node); // eslint-disable-line no-self-assign return node.assignedNodes({flatten: true}); } else { return [node]; @@ -95,8 +96,8 @@ export class FlattenedNodesObserver { } /** - * @param {Element} target Node on which to listen for changes. - * @param {?function(!Element, { target: !Element, addedNodes: !Array, removedNodes: !Array }):void} callback Function called when there are additions + * @param {!Element} target Node on which to listen for changes. + * @param {?function(this: Element, { target: !Element, addedNodes: !Array, removedNodes: !Array }):void} callback Function called when there are additions * or removals from the target's list of flattened nodes. */ constructor(target, callback) { @@ -112,7 +113,7 @@ export class FlattenedNodesObserver { this._nativeChildrenObserver = null; this._connected = false; /** - * @type {Element} + * @type {!Element} * @private */ this._target = target; @@ -142,7 +143,8 @@ export class FlattenedNodesObserver { if (isSlot(this._target)) { this._listenSlots([this._target]); } else if (this._target.children) { - this._listenSlots(this._target.children); + this._listenSlots( + /** @type {!NodeList} */ (this._target.children)); if (window.ShadyDOM) { this._shadyChildrenObserver = ShadyDOM.observeChildren(this._target, (mutations) => { @@ -171,7 +173,8 @@ export class FlattenedNodesObserver { if (isSlot(this._target)) { this._unlistenSlots([this._target]); } else if (this._target.children) { - this._unlistenSlots(this._target.children); + this._unlistenSlots( + /** @type {!NodeList} */ (this._target.children)); if (window.ShadyDOM && this._shadyChildrenObserver) { ShadyDOM.unobserveChildren(this._shadyChildrenObserver); this._shadyChildrenObserver = null; @@ -275,7 +278,7 @@ export class FlattenedNodesObserver { } /** - * @param {!Array|!NodeList} nodeList Nodes that could change + * @param {!Array|!NodeList} nodeList Nodes that could change * @return {void} * @private */ @@ -289,7 +292,7 @@ export class FlattenedNodesObserver { } /** - * @param {!Array|!NodeList} nodeList Nodes that could change + * @param {!Array|!NodeList} nodeList Nodes that could change * @return {void} * @private */ diff --git a/lib/utils/flush.js b/lib/utils/flush.js index 874eb0e55a..065a58a901 100644 --- a/lib/utils/flush.js +++ b/lib/utils/flush.js @@ -8,6 +8,9 @@ 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 */ import './boot.js'; +/* eslint-disable no-unused-vars */ +import { Debouncer } from '../utils/debounce.js'; // used in type annotations +/* eslint-enable no-unused-vars */ let debouncerQueue = []; diff --git a/lib/utils/path.js b/lib/utils/path.js index 79292692ac..52fda93c45 100644 --- a/lib/utils/path.js +++ b/lib/utils/path.js @@ -14,9 +14,6 @@ import './boot.js'; * * @summary Module with utilities for manipulating structured data path strings. */ -`TODO(modulizer): A namespace named Polymer.Path was -declared here. The surrounding comments should be reviewed, -and this string can then be deleted`; /** * Returns true if the given string is a structured data path (has dots). @@ -122,7 +119,6 @@ export function translate(base, newBase, path) { * @param {string} base Path string to test against * @param {string} path Path string to test * @return {boolean} True if `path` is equal to `base` - * @this {Path} */ export function matches(base, path) { return (base === path) || @@ -172,7 +168,6 @@ export function normalize(path) { * * @param {string | !Array} path Input path * @return {!Array} Array of path parts - * @this {Path} * @suppress {checkTypes} */ export function split(path) { @@ -192,7 +187,6 @@ export function split(path) { * (flattened) path will be set to `info.path`. * @return {*} Value at path, or `undefined` if the path could not be * fully dereferenced. - * @this {Path} */ export function get(root, path, info) { let prop = root; @@ -219,7 +213,6 @@ export function get(root, path, info) { * @param {string | !Array} path Path to set * @param {*} value Value to set to path * @return {string | undefined} The normalized version of the input path - * @this {Path} */ export function set(root, path, value) { let prop = root; diff --git a/lib/utils/render-status.js b/lib/utils/render-status.js index 1db3dd9ad4..0132699a6c 100644 --- a/lib/utils/render-status.js +++ b/lib/utils/render-status.js @@ -7,6 +7,13 @@ 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 */ + +/** + * Module for scheduling flushable pre-render and post-render tasks. + * + * @summary Module for scheduling flushable pre-render and post-render tasks. + */ + import './boot.js'; let scheduled = false; @@ -51,7 +58,13 @@ function callMethod(info) { } } -function flush() { +/** + * Flushes all `beforeNextRender` tasks, followed by all `afterNextRender` + * tasks. + * + * @return {void} + */ +export function flush() { while (beforeRenderQueue.length || afterRenderQueue.length) { flushQueue(beforeRenderQueue); flushQueue(afterRenderQueue); @@ -59,14 +72,6 @@ function flush() { scheduled = false; } -/** - * Module for scheduling flushable pre-render and post-render tasks. - * - * @summary Module for scheduling flushable pre-render and post-render tasks. - */ -`TODO(modulizer): A namespace named Polymer.RenderStatus was -declared here. The surrounding comments should be reviewed, -and this string can then be deleted`; /** * Enqueues a callback which will be run before the next render, at @@ -111,10 +116,3 @@ export function afterNextRender(context, callback, args) { afterRenderQueue.push([context, callback, args]); } -/** - * Flushes all `beforeNextRender` tasks, followed by all `afterNextRender` - * tasks. - * - * @return {void} - */ -export { flush }; diff --git a/lib/utils/style-gather.js b/lib/utils/style-gather.js index 5daadb1601..985802b70e 100644 --- a/lib/utils/style-gather.js +++ b/lib/utils/style-gather.js @@ -7,18 +7,27 @@ 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 */ + +/** + * Module with utilities for collection CSS text from ``, external + * stylesheets, and `dom-module`s. + * + * @summary Module with utilities for collection CSS text from various sources. + */ + +import { DomModule } from '../elements/dom-module.js'; import { resolveCss } from './resolve-url.js'; const MODULE_STYLE_LINK_SELECTOR = 'link[rel=import][type~=css]'; const INCLUDE_ATTR = 'include'; const SHADY_UNSCOPED_ATTR = 'shady-unscoped'; +/** + * @param {string} moduleId . + * @return {?DomModule} . + */ function importModule(moduleId) { - const /** DomModule */ PolymerDomModule = customElements.get('dom-module'); - if (!PolymerDomModule) { - return null; - } - return PolymerDomModule.import(moduleId); + return /** @type {?DomModule} */(DomModule.import(moduleId)); } function styleForImport(importDoc) { @@ -36,15 +45,6 @@ function styleForImport(importDoc) { /** @typedef {{assetpath: string}} */ let templateWithAssetPath; // eslint-disable-line no-unused-vars -/** - * Module with utilities for collection CSS text from ``, external - * stylesheets, and `dom-module`s. - * - * @summary Module with utilities for collection CSS text from various sources. - */ -`TODO(modulizer): A namespace named Polymer.StyleGather was -declared here. The surrounding comments should be reviewed, -and this string can then be deleted`; /** * Returns a list of