From 15090f2664b367b35a8855230e74e80e17184e8c Mon Sep 17 00:00:00 2001 From: Alexander Marks Date: Sat, 15 Jun 2019 22:33:17 -0700 Subject: [PATCH] Closure compilation tweaks --- lib/elements/dom-repeat.js | 2 +- lib/legacy/mutable-data-behavior.js | 1 - lib/legacy/templatizer-behavior.js | 17 +++++++++-------- lib/utils/templatize.js | 9 ++++++--- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/lib/elements/dom-repeat.js b/lib/elements/dom-repeat.js index 2983e4ba36..cd994da4b2 100644 --- a/lib/elements/dom-repeat.js +++ b/lib/elements/dom-repeat.js @@ -297,7 +297,7 @@ export class DomRepeat extends domRepeatBase { this.__sortFn = null; this.__filterFn = null; this.__observePaths = null; - /** @type {?function(new:TemplateInstanceBase, *)} */ + /** @type {?function(new:TemplateInstanceBase, Object=)} */ this.__ctor = null; this.__isDetached = true; this.template = null; diff --git a/lib/legacy/mutable-data-behavior.js b/lib/legacy/mutable-data-behavior.js index ee236668b7..c9f46b3a62 100644 --- a/lib/legacy/mutable-data-behavior.js +++ b/lib/legacy/mutable-data-behavior.js @@ -141,7 +141,6 @@ export const OptionalMutableDataBehavior = { * @param {*} value New property value * @param {*} old Previous property value * @return {boolean} Whether the property should be considered a change - * @this {this} * @protected */ _shouldPropertyChange(property, value, old) { diff --git a/lib/legacy/templatizer-behavior.js b/lib/legacy/templatizer-behavior.js index 2dfbbc3a09..b06f20496f 100644 --- a/lib/legacy/templatizer-behavior.js +++ b/lib/legacy/templatizer-behavior.js @@ -16,7 +16,7 @@ import { TemplateInstanceBase, templatize, modelForElement } from '../utils/temp * _instanceProps: Object, * _forwardHostPropV2: Function, * _notifyInstancePropV2: Function, - * ctor: TemplateInstanceBase + * ctor: function(new:TemplateInstanceBase, Object=) * }} */ let TemplatizerUser; // eslint-disable-line @@ -99,13 +99,14 @@ export const Templatizer = { */ templatize(template, mutableData) { this._templatizerTemplate = template; - this.ctor = templatize(template, this, { - mutableData: Boolean(mutableData), - parentModel: this._parentModel, - instanceProps: this._instanceProps, - forwardHostProp: this._forwardHostPropV2, - notifyInstanceProp: this._notifyInstancePropV2 - }); + this.ctor = + templatize(template, /** @type {!Polymer_PropertyEffects} */ (this), { + mutableData: Boolean(mutableData), + parentModel: this._parentModel, + instanceProps: this._instanceProps, + forwardHostProp: this._forwardHostPropV2, + notifyInstanceProp: this._notifyInstancePropV2 + }); }, /** diff --git a/lib/utils/templatize.js b/lib/utils/templatize.js index ff488c15d9..9f0321f120 100644 --- a/lib/utils/templatize.js +++ b/lib/utils/templatize.js @@ -98,6 +98,7 @@ function upgradeTemplate(template, constructor) { /** * Base class for TemplateInstance. * @constructor + * @extends {HTMLElement} * @implements {Polymer_PropertyEffects} * @private */ @@ -119,7 +120,9 @@ class TemplateInstanceBase extends templateInstanceBase { /** @type {!StampedTemplate} */ this.root = this._stampTemplate(this.__dataHost); // Save list of stamped children - let children = this.children = []; + let children = []; + /** @suppress {invalidCasts} */ + this.children = /** @type {!NodeList} */ (children); // Polymer 1.x did not use `Polymer.dom` here so not bothering. for (let n = this.root.firstChild; n; n=n.nextSibling) { children.push(n); @@ -532,8 +535,8 @@ function createNotifyHostPropEffect() { * @param {Polymer_PropertyEffects=} owner Owner of the template instances; * any optional callbacks will be bound to this owner. * @param {Object=} options Options dictionary (see summary for details) - * @return {function(new:TemplateInstanceBase)} Generated class bound to the template - * provided + * @return {function(new:TemplateInstanceBase, Object=)} Generated class bound + * to the template provided * @suppress {invalidCasts} */ export function templatize(template, owner, options) {