boolean_expression ? true : false --> boolean_expression

This commit is contained in:
kzc
2016-02-21 18:47:21 -05:00
committed by Richard van Velzen
parent 5486b68850
commit 11b0efdf84
2 changed files with 78 additions and 0 deletions

View File

@@ -2651,6 +2651,10 @@ merge(Compressor.prototype, {
// y?true:false --> !!y
if (is_true(consequent) && is_false(alternative)) {
if (self.condition.is_boolean()) {
// boolean_expression ? true : false --> boolean_expression
return self.condition;
}
self.condition = self.condition.negate(compressor);
return make_node(AST_UnaryPrefix, self.condition, {
operator: "!",