move up shorter if clause

This commit is contained in:
Dan Wolff 2018-02-04 22:46:51 +01:00
parent 1af9b79b63
commit 205978f32a

View File

@ -4807,8 +4807,12 @@ merge(Compressor.prototype, {
// XXX: intentionally falling down to the next case // XXX: intentionally falling down to the next case
case "==": 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 // "undefined" == typeof x => undefined === x
if (compressor.option("typeofs") else if (compressor.option("typeofs")
&& self.left instanceof AST_String && self.left instanceof AST_String
&& self.left.value == "undefined" && self.left.value == "undefined"
&& self.right instanceof AST_UnaryPrefix && self.right instanceof AST_UnaryPrefix
@ -4828,10 +4832,6 @@ merge(Compressor.prototype, {
&& is_object(self.left.fixed_value())) { && is_object(self.left.fixed_value())) {
return make_node(self.operator[0] == "=" ? AST_True : AST_False, self); 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; break;
case "&&": case "&&":
case "||": case "||":