if (self.left instanceof AST_String
&& self.left.value == "undefined"
&& self.right instanceof AST_UnaryPrefix
- && self.right.operator == "typeof") {
+ && self.right.operator == "typeof"
+ && compressor.option("unsafe")) {
if (!(self.right.expression instanceof AST_SymbolRef)
|| !self.right.expression.undeclared()) {
self.left = self.right.expression;
--- /dev/null
+typeof_eq_undefined: {
+ options = {
+ comparisons: true,
+ unsafe: false
+ };
+ input: { a = typeof b.c != "undefined" }
+ expect: { a = "undefined" != typeof b.c }
+}
+
+typeof_eq_undefined_unsafe: {
+ options = {
+ comparisons: true,
+ unsafe: true
+ };
+ input: { a = typeof b.c != "undefined" }
+ expect: { a = b.c !== void 0 }
+}