Skip to content

Commit 76bfc0a

Browse files
authored
Merge pull request #5546 from Polymer/sync-closure-annotations
Sync closure compiler annotations
2 parents 927ae6a + ff2edd5 commit 76bfc0a

File tree

6 files changed

+990
-1168
lines changed

6 files changed

+990
-1168
lines changed

lib/mixins/element-mixin.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,8 @@ export const ElementMixin = dedupingMixin(base => {
380380
*/
381381
static createProperties(props) {
382382
for (let p in props) {
383-
createPropertyFromConfig(this.prototype, p, props[p], props);
383+
createPropertyFromConfig(
384+
/** @type {?} */ (this.prototype), p, props[p], props);
384385
}
385386
}
386387

@@ -473,6 +474,7 @@ export const ElementMixin = dedupingMixin(base => {
473474
* Set the template.
474475
*
475476
* @param {!HTMLTemplateElement|string} value Template to set.
477+
* @nocollapse
476478
*/
477479
static set template(value) {
478480
this._template = value;

lib/mixins/properties-mixin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export const PropertiesMixin = dedupingMixin(superClass => {
154154
static _finalizeClass() {
155155
const props = ownProperties(/** @type {!PropertiesMixinConstructor} */(this));
156156
if (props) {
157-
this.createProperties(props);
157+
/** @type {?} */ (this).createProperties(props);
158158
}
159159
}
160160

lib/mixins/property-accessors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export const PropertyAccessors = dedupingMixin(superClass => {
122122
* @nocollapse
123123
*/
124124
static createPropertiesForAttributes() {
125-
let a$ = this.observedAttributes;
125+
let a$ = /** @type {?} */ (this).observedAttributes;
126126
for (let i=0; i < a$.length; i++) {
127127
this.prototype._createPropertyAccessor(dashToCamelCase(a$[i]));
128128
}

lib/mixins/template-stamp.js

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,15 @@ export const TemplateStamp = dedupingMixin(
199199
static _parseTemplate(template, outerTemplateInfo) {
200200
// since a template may be re-used, memo-ize metadata
201201
if (!template._templateInfo) {
202-
let templateInfo = template._templateInfo = {};
202+
// TODO(rictic): fix typing
203+
let /** ? */ templateInfo = template._templateInfo = {};
203204
templateInfo.nodeInfoList = [];
204205
templateInfo.stripWhiteSpace =
205206
(outerTemplateInfo && outerTemplateInfo.stripWhiteSpace) ||
206207
template.hasAttribute('strip-whitespace');
207-
this._parseTemplateContent(template, templateInfo, {parent: null});
208+
// TODO(rictic): fix typing
209+
this._parseTemplateContent(
210+
template, templateInfo, /** @type {?} */ ({parent: null}));
208211
}
209212
return template._templateInfo;
210213
}
@@ -237,16 +240,16 @@ export const TemplateStamp = dedupingMixin(
237240
* @nocollapse
238241
*/
239242
static _parseTemplateNode(node, templateInfo, nodeInfo) {
240-
let noted;
241-
let element = /** @type {Element} */(node);
243+
let noted = false;
244+
let element = /** @type {!HTMLTemplateElement} */ (node);
242245
if (element.localName == 'template' && !element.hasAttribute('preserve-content')) {
243246
noted = this._parseTemplateNestedTemplate(element, templateInfo, nodeInfo) || noted;
244247
} else if (element.localName === 'slot') {
245248
// For ShadyDom optimization, indicating there is an insertion point
246249
templateInfo.hasInsertionPoint = true;
247250
}
248251
if (element.firstChild) {
249-
noted = this._parseTemplateChildNodes(element, templateInfo, nodeInfo) || noted;
252+
this._parseTemplateChildNodes(element, templateInfo, nodeInfo);
250253
}
251254
if (element.hasAttributes && element.hasAttributes()) {
252255
noted = this._parseTemplateNodeAttributes(element, templateInfo, nodeInfo) || noted;
@@ -295,9 +298,10 @@ export const TemplateStamp = dedupingMixin(
295298
continue;
296299
}
297300
}
298-
let childInfo = { parentIndex, parentInfo: nodeInfo };
301+
let childInfo =
302+
/** @type {!NodeInfo} */ ({parentIndex, parentInfo: nodeInfo});
299303
if (this._parseTemplateNode(node, templateInfo, childInfo)) {
300-
childInfo.infoIndex = templateInfo.nodeInfoList.push(/** @type {!NodeInfo} */(childInfo)) - 1;
304+
childInfo.infoIndex = templateInfo.nodeInfoList.push(childInfo) - 1;
301305
}
302306
// Increment if not removed
303307
if (node.parentNode) {
@@ -325,10 +329,12 @@ export const TemplateStamp = dedupingMixin(
325329
* @nocollapse
326330
*/
327331
static _parseTemplateNestedTemplate(node, outerTemplateInfo, nodeInfo) {
328-
let templateInfo = this._parseTemplate(node, outerTemplateInfo);
332+
// TODO(rictic): the type of node should be non-null
333+
let element = /** @type {!HTMLTemplateElement} */ (node);
334+
let templateInfo = this._parseTemplate(element, outerTemplateInfo);
329335
let content = templateInfo.content =
330-
node.content.ownerDocument.createDocumentFragment();
331-
content.appendChild(node.content);
336+
element.content.ownerDocument.createDocumentFragment();
337+
content.appendChild(element.content);
332338
nodeInfo.templateInfo = templateInfo;
333339
return true;
334340
}
@@ -338,8 +344,9 @@ export const TemplateStamp = dedupingMixin(
338344
* for nodes of interest.
339345
*
340346
* @param {Element} node Node to parse
341-
* @param {TemplateInfo} templateInfo Template metadata for current template
342-
* @param {NodeInfo} nodeInfo Node metadata for current template.
347+
* @param {!TemplateInfo} templateInfo Template metadata for current
348+
* template
349+
* @param {!NodeInfo} nodeInfo Node metadata for current template.
343350
* @return {boolean} `true` if the visited node added node-specific
344351
* metadata to `nodeInfo`
345352
* @nocollapse

0 commit comments

Comments
 (0)