From 7513c0d41f622c3c60c67b2658ad7e45689787cf Mon Sep 17 00:00:00 2001 From: johnlenz Date: Mon, 25 Nov 2024 09:26:49 -0800 Subject: [PATCH] Simplify AliasString so that backoffs are only done one way. PiperOrigin-RevId: 700008495 --- src/com/google/javascript/jscomp/AliasStrings.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/com/google/javascript/jscomp/AliasStrings.java b/src/com/google/javascript/jscomp/AliasStrings.java index 354cec03ad0..f7a4766be63 100644 --- a/src/com/google/javascript/jscomp/AliasStrings.java +++ b/src/com/google/javascript/jscomp/AliasStrings.java @@ -116,6 +116,8 @@ public void process(Node externs, Node root) { @Override public boolean shouldTraverse(NodeTraversal nodeTraversal, Node n, Node parent) { switch (n.getToken()) { + case REGEXP: // string nodes that are children of REGEXP literals can not be aliased + case GETPROP: // string nodes that are children of GETPROP nodes can not be aliased case TEMPLATELIT: case TAGGED_TEMPLATELIT: case TEMPLATELIT_SUB: // technically redundant, since it must be a child of the others @@ -131,7 +133,7 @@ public boolean shouldTraverse(NodeTraversal nodeTraversal, Node n, Node parent) @Override public void visit(NodeTraversal t, Node n, Node parent) { - if (n.isStringLit() && !parent.isRegExp()) { + if (n.isStringLit()) { String str = n.getString(); // "undefined" is special-cased, since it needs to be used when JS code