aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 091ad9e5..54873f0d 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];
+ }
+ }
+ }
+ else 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);