diff --git a/lib/compress.js b/lib/compress.js index cd74389b..688c0c74 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -4807,8 +4807,12 @@ merge(Compressor.prototype, { // XXX: intentionally falling down to the next case case "==": case "!=": + // void 0 == x => null == x + if (!is_strict_comparison && is_undefined(self.left, compressor)) { + self.left = make_node(AST_Null, self.left); + } // "undefined" == typeof x => undefined === x - if (compressor.option("typeofs") + else if (compressor.option("typeofs") && self.left instanceof AST_String && self.left.value == "undefined" && self.right instanceof AST_UnaryPrefix @@ -4828,10 +4832,6 @@ merge(Compressor.prototype, { && is_object(self.left.fixed_value())) { return make_node(self.operator[0] == "=" ? AST_True : AST_False, self); } - // void 0 == x => null == x - else if (!is_strict_comparison && is_undefined(self.left, compressor)) { - self.left = make_node(AST_Null, self.left); - } break; case "&&": case "||":