Skip to content

Commit

Permalink
Fix ValidityCheck violations in PolymerPass.
Browse files Browse the repository at this point in the history
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=174244875
  • Loading branch information
tbreisacher authored and brad4d committed Nov 2, 2017
1 parent 84a0a6f commit 46104a8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
16 changes: 9 additions & 7 deletions src/com/google/javascript/jscomp/PolymerClassRewriter.java
Expand Up @@ -143,7 +143,7 @@ void rewritePolymerCall(
if (this.polymerVersion == 1 && !isInGlobalScope && !cls.target.isGetProp()) {
Node scriptNode = NodeUtil.getEnclosingScript(parent);
scriptNode.addChildrenToFront(statements);
compiler.reportChangeToEnclosingScope(scriptNode);
compiler.reportChangeToChangeScope(scriptNode);
} else {
Node beforeRoot = exprRoot.getPrevious();
if (beforeRoot == null) {
Expand All @@ -155,14 +155,16 @@ void rewritePolymerCall(
}
compiler.reportChangeToEnclosingScope(statements);

// Since behavior files might contain more language features than the class file, we need to
// update the feature sets.
FeatureSet newFeatures = cls.features;
if (newFeatures != null) {
// Since behavior files might contain language features that aren't present in the class file,
// we might need to update the FeatureSet.
if (cls.features != null) {
Node scriptNode = NodeUtil.getEnclosingScript(parent);
FeatureSet oldFeatures = (FeatureSet) scriptNode.getProp(Node.FEATURE_SET);
scriptNode.putProp(Node.FEATURE_SET, oldFeatures.union(newFeatures));
compiler.reportChangeToEnclosingScope(scriptNode);
FeatureSet newFeatures = oldFeatures.union(cls.features);
if (!newFeatures.equals(oldFeatures)) {
scriptNode.putProp(Node.FEATURE_SET, newFeatures);
compiler.reportChangeToChangeScope(scriptNode);
}
}

if (NodeUtil.isNameDeclaration(exprRoot)) {
Expand Down
6 changes: 4 additions & 2 deletions src/com/google/javascript/jscomp/PolymerPassStaticUtils.java
Expand Up @@ -91,8 +91,10 @@ static void quoteListenerAndHostAttributeKeys(Node objLit, AbstractCompiler comp
continue;
}
for (Node keyToQuote : keyNode.getFirstChild().children()) {
keyToQuote.setQuotedString();
compiler.reportChangeToEnclosingScope(keyToQuote);
if (!keyToQuote.isQuotedString()) {
keyToQuote.setQuotedString();
compiler.reportChangeToEnclosingScope(keyToQuote);
}
}
}
}
Expand Down

0 comments on commit 46104a8

Please sign in to comment.