diff options
-rw-r--r-- | lib/compress.js | 2 | ||||
-rw-r--r-- | test/compress/issue-751.js | 29 |
2 files changed, 30 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js index 54873f0d..4c4cf977 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -2183,7 +2183,7 @@ merge(Compressor.prototype, { } break; } - if (compressor.option("comparisons")) { + if (compressor.option("comparisons") && self.is_boolean()) { if (!(compressor.parent() instanceof AST_Binary) || compressor.parent() instanceof AST_Assign) { var negated = make_node(AST_UnaryPrefix, self, { diff --git a/test/compress/issue-751.js b/test/compress/issue-751.js new file mode 100644 index 00000000..829b7ca5 --- /dev/null +++ b/test/compress/issue-751.js @@ -0,0 +1,29 @@ +negate_booleans_1: { + options = { + comparisons: true + }; + input: { + var a = !a || !b || !c || !d || !e || !f; + } + expect: { + var a = !(a && b && c && d && e && f); + } +} + +negate_booleans_2: { + options = { + comparisons: true + }; + input: { + var match = !x && // should not touch this one + (!z || c) && + (!k || d) && + the_stuff(); + } + expect: { + var match = !x && + (!z || c) && + (!k || d) && + the_stuff(); + } +} |