enable typeof "undefined" for general use
move out of unsafe, guard corner case with screw_id8 instead closes #1446
This commit is contained in:
@@ -2504,14 +2504,15 @@ merge(Compressor.prototype, {
|
||||
// XXX: intentionally falling down to the next case
|
||||
case "==":
|
||||
case "!=":
|
||||
// "undefined" == typeof x => undefined === x
|
||||
if (self.left instanceof AST_String
|
||||
&& self.left.value == "undefined"
|
||||
&& self.right instanceof AST_UnaryPrefix
|
||||
&& self.right.operator == "typeof"
|
||||
&& compressor.option("unsafe")) {
|
||||
if (!(self.right.expression instanceof AST_SymbolRef)
|
||||
|| !self.right.expression.undeclared()) {
|
||||
self.right = self.right.expression;
|
||||
&& self.right.operator == "typeof") {
|
||||
var expr = self.right.expression;
|
||||
if (expr instanceof AST_SymbolRef ? !expr.undeclared()
|
||||
: !(expr instanceof AST_PropAccess) || compressor.option("screw_ie8")) {
|
||||
self.right = expr;
|
||||
self.left = make_node(AST_Undefined, self.left).optimize(compressor);
|
||||
if (self.operator.length == 2) self.operator += "=";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user