25
25
/**
26
26
* For every Polymer Behavior, strip property type annotations and add suppress checktypes on
27
27
* functions.
28
+ *
29
+ * <p>Also find listener and hostAttribute keys in the behavior, and mark them as quoted. This
30
+ * protects the keys from being renamed.
28
31
*/
29
- final class PolymerPassSuppressBehaviors extends ExternsSkippingCallback {
32
+ final class PolymerPassSuppressBehaviorsAndProtectKeys extends ExternsSkippingCallback {
30
33
31
34
private final AbstractCompiler compiler ;
32
35
33
- PolymerPassSuppressBehaviors (AbstractCompiler compiler ) {
36
+ PolymerPassSuppressBehaviorsAndProtectKeys (AbstractCompiler compiler ) {
34
37
this .compiler = compiler ;
35
38
}
36
39
@@ -42,6 +45,10 @@ public void visit(NodeTraversal t, Node n, Node parent) {
42
45
return ;
43
46
}
44
47
48
+ // Find listener and hostAttribute keys in the behavior, and mark them as quoted.
49
+ // This ensures that the keys are not renamed.
50
+ traverseBehaviorandfindListenerAndHostAttributeAndMarkKeysAsQuoted (n );
51
+
45
52
// Add @nocollapse.
46
53
JSDocInfo .Builder newDocs = JSDocInfo .Builder .maybeCopyFrom (n .getJSDocInfo ());
47
54
newDocs .recordNoCollapse ();
@@ -55,6 +62,17 @@ public void visit(NodeTraversal t, Node n, Node parent) {
55
62
}
56
63
}
57
64
65
+ /** Traverse the behavior, find listener and hostAttribute keys, and mark them as quoted. */
66
+ private void traverseBehaviorandfindListenerAndHostAttributeAndMarkKeysAsQuoted (Node n ) {
67
+ if (n .isObjectLit ()) {
68
+ PolymerPassStaticUtils .quoteListenerAndHostAttributeKeys (n , compiler );
69
+ }
70
+
71
+ for (Node child = n .getFirstChild (); child != null ; child = child .getNext ()) {
72
+ traverseBehaviorandfindListenerAndHostAttributeAndMarkKeysAsQuoted (child );
73
+ }
74
+ }
75
+
58
76
/** Strip property type annotations and add suppressions on functions. */
59
77
private void suppressBehavior (Node behaviorValue , Node reportNode ) {
60
78
if (behaviorValue == null ) {
0 commit comments