aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-03-03 07:12:24 +0800
committerGitHub <noreply@github.com>2017-03-03 07:12:24 +0800
commitb5e0e8c2038c7c0ea13771891eb84f6e6f7bcbc3 (patch)
treede0ac594f7146860b718b367ef67a67930adfff0 /lib/compress.js
parente5cb9275df257751b7322f34bca5e76cc519b974 (diff)
downloadtracifyjs-b5e0e8c2038c7c0ea13771891eb84f6e6f7bcbc3.tar.gz
tracifyjs-b5e0e8c2038c7c0ea13771891eb84f6e6f7bcbc3.zip
facilitate fix for #1531 (#1542)
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js15
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);