aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 406a331c..9760c546 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -5278,6 +5278,20 @@ merge(Compressor.prototype, {
consequent
]).optimize(compressor);
}
+ // x ? y || z : z --> x && y || z
+ if (consequent instanceof AST_Binary
+ && consequent.operator == "||"
+ && consequent.right.equivalent_to(alternative)) {
+ return make_node(AST_Binary, self, {
+ operator: "||",
+ left: make_node(AST_Binary, self, {
+ operator: "&&",
+ left: self.condition,
+ right: consequent.left
+ }),
+ right: alternative
+ }).optimize(compressor);
+ }
var in_bool = compressor.in_boolean_context();
if (is_true(self.consequent)) {
if (is_false(self.alternative)) {