diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-02-08 10:31:08 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-08 18:31:08 +0800 |
commit | 357d8612462c826f9e0e85b4d3a1c790f6de7057 (patch) | |
tree | 3f467e4caaf28625b0b240cb12bf461d762fe05e /lib/compress.js | |
parent | fd4caf7a9cbfaa482d8cc77d2bc8cd00e8bc256a (diff) | |
download | tracifyjs-357d8612462c826f9e0e85b4d3a1c790f6de7057.tar.gz tracifyjs-357d8612462c826f9e0e85b4d3a1c790f6de7057.zip |
fix corner case in `conditionals` (#4624)
fixes #4623
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 47 |
1 files changed, 19 insertions, 28 deletions
diff --git a/lib/compress.js b/lib/compress.js index 9e9f15f6..591f28a8 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -4466,34 +4466,6 @@ merge(Compressor.prototype, { def(AST_Statement, function() { throw new Error("Cannot negate a statement"); }); - def(AST_Arrow, function() { - return basic_negation(this); - }); - def(AST_AsyncArrow, function() { - return basic_negation(this); - }); - def(AST_AsyncFunction, function() { - return basic_negation(this); - }); - def(AST_Function, function() { - return basic_negation(this); - }); - def(AST_UnaryPrefix, function() { - if (this.operator == "!") - return this.expression; - return basic_negation(this); - }); - def(AST_Sequence, function(compressor) { - var expressions = this.expressions.slice(); - expressions.push(expressions.pop().negate(compressor)); - return make_sequence(this, expressions); - }); - def(AST_Conditional, function(compressor, first_in_statement) { - var self = this.clone(); - self.consequent = self.consequent.negate(compressor); - self.alternative = self.alternative.negate(compressor); - return best(this, self, first_in_statement); - }); def(AST_Binary, function(compressor, first_in_statement) { var self = this.clone(), op = this.operator; if (compressor.option("unsafe_comps")) { @@ -4522,6 +4494,25 @@ merge(Compressor.prototype, { } return basic_negation(this); }); + def(AST_Conditional, function(compressor, first_in_statement) { + var self = this.clone(); + self.consequent = self.consequent.negate(compressor); + self.alternative = self.alternative.negate(compressor); + return best(this, self, first_in_statement); + }); + def(AST_LambdaExpression, function() { + return basic_negation(this); + }); + def(AST_Sequence, function(compressor) { + var expressions = this.expressions.slice(); + expressions.push(expressions.pop().negate(compressor)); + return make_sequence(this, expressions); + }); + def(AST_UnaryPrefix, function() { + if (this.operator == "!") + return this.expression; + return basic_negation(this); + }); })(function(node, func) { node.DEFMETHOD("negate", function(compressor, first_in_statement) { return func.call(this, compressor, first_in_statement); |