From ad0842017d55825b0e5b58f0a5aeab9c682aafe5 Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Tue, 21 May 2019 17:14:50 -0700 Subject: [PATCH] Sync closure compiler annotations Synced from cl/245073668 --- lib/mixins/element-mixin.js | 4 +++- lib/mixins/properties-mixin.js | 2 +- lib/mixins/property-accessors.js | 2 +- lib/mixins/template-stamp.js | 31 +++++++++++++++++++------------ 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/lib/mixins/element-mixin.js b/lib/mixins/element-mixin.js index 7e40fc0039..ab10624cc2 100644 --- a/lib/mixins/element-mixin.js +++ b/lib/mixins/element-mixin.js @@ -380,7 +380,8 @@ export const ElementMixin = dedupingMixin(base => { */ static createProperties(props) { for (let p in props) { - createPropertyFromConfig(this.prototype, p, props[p], props); + createPropertyFromConfig( + /** @type {?} */ (this.prototype), p, props[p], props); } } @@ -473,6 +474,7 @@ export const ElementMixin = dedupingMixin(base => { * Set the template. * * @param {!HTMLTemplateElement|string} value Template to set. + * @nocollapse */ static set template(value) { this._template = value; diff --git a/lib/mixins/properties-mixin.js b/lib/mixins/properties-mixin.js index 67ebb9b509..d450cfd299 100644 --- a/lib/mixins/properties-mixin.js +++ b/lib/mixins/properties-mixin.js @@ -154,7 +154,7 @@ export const PropertiesMixin = dedupingMixin(superClass => { static _finalizeClass() { const props = ownProperties(/** @type {!PropertiesMixinConstructor} */(this)); if (props) { - this.createProperties(props); + /** @type {?} */ (this).createProperties(props); } } diff --git a/lib/mixins/property-accessors.js b/lib/mixins/property-accessors.js index 26dcc95ffc..16d039ef82 100644 --- a/lib/mixins/property-accessors.js +++ b/lib/mixins/property-accessors.js @@ -122,7 +122,7 @@ export const PropertyAccessors = dedupingMixin(superClass => { * @nocollapse */ static createPropertiesForAttributes() { - let a$ = this.observedAttributes; + let a$ = /** @type {?} */ (this).observedAttributes; for (let i=0; i < a$.length; i++) { this.prototype._createPropertyAccessor(dashToCamelCase(a$[i])); } diff --git a/lib/mixins/template-stamp.js b/lib/mixins/template-stamp.js index e34e408995..99313a1165 100644 --- a/lib/mixins/template-stamp.js +++ b/lib/mixins/template-stamp.js @@ -199,12 +199,15 @@ export const TemplateStamp = dedupingMixin( static _parseTemplate(template, outerTemplateInfo) { // since a template may be re-used, memo-ize metadata if (!template._templateInfo) { - let templateInfo = template._templateInfo = {}; + // TODO(rictic): fix typing + let /** ? */ templateInfo = template._templateInfo = {}; templateInfo.nodeInfoList = []; templateInfo.stripWhiteSpace = (outerTemplateInfo && outerTemplateInfo.stripWhiteSpace) || template.hasAttribute('strip-whitespace'); - this._parseTemplateContent(template, templateInfo, {parent: null}); + // TODO(rictic): fix typing + this._parseTemplateContent( + template, templateInfo, /** @type {?} */ ({parent: null})); } return template._templateInfo; } @@ -237,8 +240,8 @@ export const TemplateStamp = dedupingMixin( * @nocollapse */ static _parseTemplateNode(node, templateInfo, nodeInfo) { - let noted; - let element = /** @type {Element} */(node); + let noted = false; + let element = /** @type {!HTMLTemplateElement} */ (node); if (element.localName == 'template' && !element.hasAttribute('preserve-content')) { noted = this._parseTemplateNestedTemplate(element, templateInfo, nodeInfo) || noted; } else if (element.localName === 'slot') { @@ -246,7 +249,7 @@ export const TemplateStamp = dedupingMixin( templateInfo.hasInsertionPoint = true; } if (element.firstChild) { - noted = this._parseTemplateChildNodes(element, templateInfo, nodeInfo) || noted; + this._parseTemplateChildNodes(element, templateInfo, nodeInfo); } if (element.hasAttributes && element.hasAttributes()) { noted = this._parseTemplateNodeAttributes(element, templateInfo, nodeInfo) || noted; @@ -295,9 +298,10 @@ export const TemplateStamp = dedupingMixin( continue; } } - let childInfo = { parentIndex, parentInfo: nodeInfo }; + let childInfo = + /** @type {!NodeInfo} */ ({parentIndex, parentInfo: nodeInfo}); if (this._parseTemplateNode(node, templateInfo, childInfo)) { - childInfo.infoIndex = templateInfo.nodeInfoList.push(/** @type {!NodeInfo} */(childInfo)) - 1; + childInfo.infoIndex = templateInfo.nodeInfoList.push(childInfo) - 1; } // Increment if not removed if (node.parentNode) { @@ -325,10 +329,12 @@ export const TemplateStamp = dedupingMixin( * @nocollapse */ static _parseTemplateNestedTemplate(node, outerTemplateInfo, nodeInfo) { - let templateInfo = this._parseTemplate(node, outerTemplateInfo); + // TODO(rictic): the type of node should be non-null + let element = /** @type {!HTMLTemplateElement} */ (node); + let templateInfo = this._parseTemplate(element, outerTemplateInfo); let content = templateInfo.content = - node.content.ownerDocument.createDocumentFragment(); - content.appendChild(node.content); + element.content.ownerDocument.createDocumentFragment(); + content.appendChild(element.content); nodeInfo.templateInfo = templateInfo; return true; } @@ -338,8 +344,9 @@ export const TemplateStamp = dedupingMixin( * for nodes of interest. * * @param {Element} node Node to parse - * @param {TemplateInfo} templateInfo Template metadata for current template - * @param {NodeInfo} nodeInfo Node metadata for current template. + * @param {!TemplateInfo} templateInfo Template metadata for current + * template + * @param {!NodeInfo} nodeInfo Node metadata for current template. * @return {boolean} `true` if the visited node added node-specific * metadata to `nodeInfo` * @nocollapse