diff options
author | Mihai Bazon <mihai@bazon.net> | 2013-11-20 21:13:16 +0200 |
---|---|---|
committer | Mihai Bazon <mihai@bazon.net> | 2013-11-20 21:13:16 +0200 |
commit | 50b8d7272c3b0c7a222e5d6e433c9736f920434c (patch) | |
tree | aecf124650cbbd71a4d9105c51de691fa0544f5e | |
parent | 7d11b96f48f7f03727fa664d540484f214cadca2 (diff) | |
download | tracifyjs-50b8d7272c3b0c7a222e5d6e433c9736f920434c.tar.gz tracifyjs-50b8d7272c3b0c7a222e5d6e433c9736f920434c.zip |
Fix faulty compression
`String(x + 5)` is not always the same as `x + "5"`. Overlooked that. :-(
Close #350
-rw-r--r-- | lib/compress.js | 10 | ||||
-rw-r--r-- | test/compress/issue-269.js | 8 |
2 files changed, 3 insertions, 15 deletions
diff --git a/lib/compress.js b/lib/compress.js index c60ee19e..3cc59e2c 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -2031,16 +2031,6 @@ merge(Compressor.prototype, { && self.right.getValue() === "" && self.left instanceof AST_Binary && self.left.operator == "+" && self.left.is_string(compressor)) { 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 (self.operator == "+") { diff --git a/test/compress/issue-269.js b/test/compress/issue-269.js index 70e82d08..1d41dea6 100644 --- a/test/compress/issue-269.js +++ b/test/compress/issue-269.js @@ -54,15 +54,13 @@ strings_concat: { input: { f( String(x + 'str'), - String('str' + x), - String(x + 5) + String('str' + x) ); } expect: { f( x + 'str', - 'str' + x, - x + '5' + 'str' + x ); } -}
\ No newline at end of file +} |