fix reduce_vars on conditionals

This commit is contained in:
alexlamsl 2017-04-18 00:39:20 +08:00
parent 6d5f341999
commit 9889ec43fc
2 changed files with 33 additions and 0 deletions

View File

@ -348,6 +348,16 @@ merge(Compressor.prototype, {
pop(); pop();
return true; return true;
} }
if (node instanceof AST_Conditional) {
node.condition.walk(tw);
push();
node.consequent.walk(tw);
pop();
push();
node.alternative.walk(tw);
pop();
return true;
}
if (node instanceof AST_If) { if (node instanceof AST_If) {
node.condition.walk(tw); node.condition.walk(tw);
push(); push();

View File

@ -2240,3 +2240,26 @@ boolean_binary_assign: {
} }
expect_stdout: "undefined" expect_stdout: "undefined"
} }
cond_assign: {
options = {
evaluate: true,
reduce_vars: true,
unused: true,
}
input: {
!function() {
var a;
void 0 ? (a = 1) : 0;
console.log(a);
}();
}
expect: {
!function() {
var a;
void 0 ? (a = 1) : 0;
console.log(a);
}();
}
expect_stdout: "undefined"
}