fix collapse_vars on switch (#2578)

This commit is contained in:
Alex Lam S.L
2017-12-11 18:11:09 +08:00
committed by GitHub
parent c43118be4f
commit f2ad542679
2 changed files with 61 additions and 7 deletions

View File

@@ -873,14 +873,12 @@ merge(Compressor.prototype, {
node.expression = node.expression.transform(scanner);
for (var i = 0, len = node.body.length; !abort && i < len; i++) {
var branch = node.body[i];
if (branch instanceof AST_Case)
if (branch instanceof AST_Case) {
branch.expression = branch.expression.transform(scanner);
if (side_effects || !replace_all) break;
}
}
for (i = 0; !abort && i < len; i++) {
var branch = node.body[i];
for (var j = 0, len2 = branch.body.length; j < len2; j++)
branch.body[j] = branch.body[j].transform(scanner);
}
abort = true;
return node;
}
// Skip nodes before `candidate` as quickly as possible