diff options
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js index 530e7c2f..34233143 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -2104,6 +2104,34 @@ merge(Compressor.prototype, { } break; } + if (compressor.option("conditionals")) { + if (self.operator == "&&") { + var ll = self.left.evaluate(compressor); + var rr = self.right.evaluate(compressor); + if (ll.length > 1) { + if (ll[1]) { + compressor.warn("Condition left of && always true [{file}:{line},{col}]", self.start); + return rr[0]; + } else { + compressor.warn("Condition left of && always false [{file}:{line},{col}]", self.start); + return ll[0]; + } + } + } + if (self.operator == "||") { + var ll = self.left.evaluate(compressor); + var rr = self.right.evaluate(compressor); + if (ll.length > 1) { + if (ll[1]) { + compressor.warn("Condition left of || always true [{file}:{line},{col}]", self.start); + return ll[0]; + } else { + compressor.warn("Condition left of || always false [{file}:{line},{col}]", self.start); + return rr[0]; + } + } + } + } if (compressor.option("booleans") && compressor.in_boolean_context()) switch (self.operator) { case "&&": var ll = self.left.evaluate(compressor); |