@@ -1840,6 +1840,8 @@ merge(Compressor.prototype, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
OPT(AST_If, function(self, compressor){
|
OPT(AST_If, function(self, compressor){
|
||||||
|
if (is_empty(self.alternative)) self.alternative = null;
|
||||||
|
|
||||||
if (!compressor.option("conditionals")) return self;
|
if (!compressor.option("conditionals")) return self;
|
||||||
// if condition can be statically determined, warn and drop
|
// if condition can be statically determined, warn and drop
|
||||||
// one of the blocks. note, statically determined implies
|
// one of the blocks. note, statically determined implies
|
||||||
@@ -1868,7 +1870,6 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (is_empty(self.alternative)) self.alternative = null;
|
|
||||||
var negated = self.condition.negate(compressor);
|
var negated = self.condition.negate(compressor);
|
||||||
var self_condition_length = self.condition.print_to_string().length;
|
var self_condition_length = self.condition.print_to_string().length;
|
||||||
var negated_length = negated.print_to_string().length;
|
var negated_length = negated.print_to_string().length;
|
||||||
|
|||||||
45
test/compress/issue-1447.js
Normal file
45
test/compress/issue-1447.js
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
else_with_empty_block: {
|
||||||
|
options = {}
|
||||||
|
input: {
|
||||||
|
if (x)
|
||||||
|
yes();
|
||||||
|
else {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_exact: "if(x)yes();"
|
||||||
|
}
|
||||||
|
|
||||||
|
else_with_empty_statement: {
|
||||||
|
options = {}
|
||||||
|
input: {
|
||||||
|
if (x)
|
||||||
|
yes();
|
||||||
|
else
|
||||||
|
;
|
||||||
|
}
|
||||||
|
expect_exact: "if(x)yes();"
|
||||||
|
}
|
||||||
|
|
||||||
|
conditional_false_stray_else_in_loop: {
|
||||||
|
options = {
|
||||||
|
evaluate : true,
|
||||||
|
comparisons : true,
|
||||||
|
booleans : true,
|
||||||
|
unused : true,
|
||||||
|
loops : true,
|
||||||
|
side_effects : true,
|
||||||
|
dead_code : true,
|
||||||
|
hoist_vars : true,
|
||||||
|
join_vars : true,
|
||||||
|
if_return : true,
|
||||||
|
cascade : true,
|
||||||
|
conditionals : false,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
for (var i = 1; i <= 4; ++i) {
|
||||||
|
if (i <= 2) continue;
|
||||||
|
console.log(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_exact: "for(var i=1;i<=4;++i)if(!(i<=2))console.log(i);"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user