aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/compress.js2
-rw-r--r--test/compress/nullish.js19
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 7f9a8dd5..93023e19 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -3618,6 +3618,8 @@ merge(Compressor.prototype, {
return this.left.is_defined(compressor) && this.right.is_defined(compressor);
case "||":
return this.left.is_truthy() || this.right.is_defined(compressor);
+ case "??":
+ return this.left.is_defined(compressor) || this.right.is_defined(compressor);
default:
return true;
}
diff --git a/test/compress/nullish.js b/test/compress/nullish.js
index e8f5ad6c..a8526cac 100644
--- a/test/compress/nullish.js
+++ b/test/compress/nullish.js
@@ -109,3 +109,22 @@ conditional_assignment_4: {
expect_stdout: "PASS"
node_version: ">=14"
}
+
+issue_4679: {
+ options = {
+ comparisons: true,
+ ie8: true,
+ }
+ input: {
+ var a;
+ if (void 0 === (undefined ?? a))
+ console.log("PASS");
+ }
+ expect: {
+ var a;
+ if (void 0 === (undefined ?? a))
+ console.log("PASS");
+ }
+ expect_stdout: "PASS"
+ node_version: ">=14"
+}