diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-03-03 07:12:24 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-03 07:12:24 +0800 |
commit | b5e0e8c2038c7c0ea13771891eb84f6e6f7bcbc3 (patch) | |
tree | de0ac594f7146860b718b367ef67a67930adfff0 | |
parent | e5cb9275df257751b7322f34bca5e76cc519b974 (diff) | |
download | tracifyjs-b5e0e8c2038c7c0ea13771891eb84f6e6f7bcbc3.tar.gz tracifyjs-b5e0e8c2038c7c0ea13771891eb84f6e6f7bcbc3.zip |
facilitate fix for #1531 (#1542)
-rw-r--r-- | lib/compress.js | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/compress.js b/lib/compress.js index 0cc9c518..38ebbf40 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -181,6 +181,13 @@ merge(Compressor.prototype, { var reduce_vars = rescan && compressor.option("reduce_vars"); var safe_ids = []; push(); + var suppressor = new TreeWalker(function(node) { + if (node instanceof AST_Symbol) { + var d = node.definition(); + if (node instanceof AST_SymbolRef) d.references.push(node); + d.fixed = false; + } + }); var tw = new TreeWalker(function(node){ if (!(node instanceof AST_Directive || node instanceof AST_Constant)) { node._squeezed = false; @@ -243,13 +250,7 @@ merge(Compressor.prototype, { return true; } if (node instanceof AST_ForIn) { - var sym = node.init; - if (sym instanceof AST_Var) { - sym = sym.definitions[0].name; - } - var d = sym.definition(); - d.references.push(sym); - d.fixed = false; + node.init.walk(suppressor); node.object.walk(tw); push(); node.body.walk(tw); |