parent
e6a2e9e4d0
commit
7f67c56d64
|
|
@ -4858,6 +4858,12 @@ merge(Compressor.prototype, {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// void 0 == x => null == x
|
||||||
|
if (compressor.option("comparisons") &&
|
||||||
|
(self.operator == "==" || self.operator == "!=") &&
|
||||||
|
is_undefined(self.left, compressor)) {
|
||||||
|
self.left = make_node_from_constant(null, self.left);
|
||||||
|
}
|
||||||
if (self.operator == "+" && compressor.in_boolean_context()) {
|
if (self.operator == "+" && compressor.in_boolean_context()) {
|
||||||
var ll = self.left.evaluate(compressor);
|
var ll = self.left.evaluate(compressor);
|
||||||
var rr = self.right.evaluate(compressor);
|
var rr = self.right.evaluate(compressor);
|
||||||
|
|
|
||||||
17
test/compress/issue-2871.js
Normal file
17
test/compress/issue-2871.js
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
comparison_with_undefined: {
|
||||||
|
options = {
|
||||||
|
comparisons: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
a == undefined
|
||||||
|
a != undefined
|
||||||
|
a === undefined
|
||||||
|
a !== undefined
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
null == a
|
||||||
|
null != a
|
||||||
|
void 0 === a
|
||||||
|
void 0 !== a
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user