Fix faulty compression
`String(x + 5)` is not always the same as `x + "5"`. Overlooked that. :-( Close #350
This commit is contained in:
@@ -2031,16 +2031,6 @@ merge(Compressor.prototype, {
|
|||||||
&& self.right.getValue() === "" && self.left instanceof AST_Binary
|
&& self.right.getValue() === "" && self.left instanceof AST_Binary
|
||||||
&& self.left.operator == "+" && self.left.is_string(compressor)) {
|
&& self.left.operator == "+" && self.left.is_string(compressor)) {
|
||||||
return self.left;
|
return self.left;
|
||||||
} else if (self.operator == "+" && self.right instanceof AST_String
|
|
||||||
&& self.right.getValue() === "" && self.left instanceof AST_Binary
|
|
||||||
&& self.left.operator == "+" && self.left.right instanceof AST_Number) {
|
|
||||||
return make_node(AST_Binary, self, {
|
|
||||||
left: self.left.left,
|
|
||||||
operator: "+",
|
|
||||||
right: make_node(AST_String, self.right, {
|
|
||||||
value: String(self.left.right.value)
|
|
||||||
})
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (compressor.option("evaluate")) {
|
if (compressor.option("evaluate")) {
|
||||||
if (self.operator == "+") {
|
if (self.operator == "+") {
|
||||||
|
|||||||
@@ -54,15 +54,13 @@ strings_concat: {
|
|||||||
input: {
|
input: {
|
||||||
f(
|
f(
|
||||||
String(x + 'str'),
|
String(x + 'str'),
|
||||||
String('str' + x),
|
String('str' + x)
|
||||||
String(x + 5)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
f(
|
f(
|
||||||
x + 'str',
|
x + 'str',
|
||||||
'str' + x,
|
'str' + x
|
||||||
x + '5'
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user