moved typeof foo == "undefined" ==> foo === undefined under --unsafe

because 43fd45154b (commitcomment-1864505)
This commit is contained in:
Mihai Bazon
2012-09-17 18:49:52 +03:00
parent e370e3b5a4
commit ee669ba878

View File

@@ -1371,21 +1371,23 @@ function Compressor(options, false_by_default) {
// XXX: intentionally falling down to the next case // XXX: intentionally falling down to the next case
case "==": case "==":
case "!=": case "!=":
if (this.left instanceof AST_UnaryPrefix if (compressor.option("unsafe")) {
&& this.left.operator == "typeof" if (this.left instanceof AST_UnaryPrefix
&& this.right instanceof AST_String && this.left.operator == "typeof"
&& this.right.value == "undefined") { && this.right instanceof AST_String
this.left = this.left.expression; && this.right.value == "undefined") {
this.right = make_node(AST_Undefined, this.right).optimize(compressor); this.left = this.left.expression;
if (this.operator.length == 2) this.operator += "="; this.right = make_node(AST_Undefined, this.right).optimize(compressor);
} if (this.operator.length == 2) this.operator += "=";
else if (this.left instanceof AST_String }
&& this.left.value == "undefined" else if (this.left instanceof AST_String
&& this.right instanceof AST_UnaryPrefix && this.left.value == "undefined"
&& this.right.operator == "typeof") { && this.right instanceof AST_UnaryPrefix
this.left = this.right.expression; && this.right.operator == "typeof") {
this.right = make_node(AST_Undefined, this.left).optimize(compressor); this.left = this.right.expression;
if (this.operator.length == 2) this.operator += "="; this.right = make_node(AST_Undefined, this.left).optimize(compressor);
if (this.operator.length == 2) this.operator += "=";
}
} }
break; break;
} }