Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync closure compiler annotations #5546

Merged
merged 2 commits into from
May 22, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/mixins/element-mixin.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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