diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/compress.js b/lib/compress.js index b3edb840..cbcb7b86 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -3550,19 +3550,17 @@ merge(Compressor.prototype, { } var consequent = self.consequent; var alternative = self.alternative; + // if (foo) exp = something; else exp = something_else; + // | + // v + // exp = foo ? something : something_else; if (consequent instanceof AST_Assign && alternative instanceof AST_Assign && consequent.operator == alternative.operator && consequent.left.equivalent_to(alternative.left) - && (!consequent.left.has_side_effects(compressor) - || !self.condition.has_side_effects(compressor)) - ) { - /* - * Stuff like this: - * if (foo) exp = something; else exp = something_else; - * ==> - * exp = foo ? something : something_else; - */ + && (!self.condition.has_side_effects(compressor) + || consequent.operator == "=" + && !consequent.left.has_side_effects(compressor))) { return make_node(AST_Assign, self, { operator: consequent.operator, left: consequent.left, |