Skip to content

Commit

Permalink
Sync closure compiler annotations
Browse files Browse the repository at this point in the history
Synced from cl/245073668
  • Loading branch information
dfreedm committed May 22, 2019
1 parent 927ae6a commit ad08420
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
4 changes: 3 additions & 1 deletion lib/mixins/element-mixin.js
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/mixins/properties-mixin.js
Expand Up @@ -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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/mixins/property-accessors.js
Expand Up @@ -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]));
}
Expand Down
31 changes: 19 additions & 12 deletions lib/mixins/template-stamp.js
Expand Up @@ -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;
}
Expand Down Expand Up @@ -237,16 +240,16 @@ 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') {
// For ShadyDom optimization, indicating there is an insertion point
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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand All @@ -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
Expand Down

0 comments on commit ad08420

Please sign in to comment.