From 9cd118ca3d3e9882e4ecb14b153aa05cb070b453 Mon Sep 17 00:00:00 2001 From: Mark Jaquith Date: Fri, 25 Oct 2013 16:28:15 -0400 Subject: [PATCH 1/2] Add a unit test for issue-126 Add a unit test to test to test for aggressive parenthesis removal that causes functional changes. --- test/compress/issue-126.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/compress/issue-126.js b/test/compress/issue-126.js index 1e654941..7a597b87 100644 --- a/test/compress/issue-126.js +++ b/test/compress/issue-126.js @@ -10,6 +10,7 @@ concatenate_rhs_strings: { foo(bar() + 123 + "Hello" + "World" + ("Foo" + "Bar")); foo("Foo" + "Bar" + bar() + 123 + "Hello" + "World" + ("Foo" + "Bar")); foo("Hello" + bar() + 123 + "World"); + foo(bar() + 'Foo' + (10 + parseInt('10'))); } expect: { foo(bar() + 123 + "HelloWorld"); @@ -18,5 +19,6 @@ concatenate_rhs_strings: { foo(bar() + 123 + "HelloWorldFooBar"); foo("FooBar" + bar() + "123HelloWorldFooBar"); foo("Hello" + bar() + "123World"); + foo(bar() + 'Foo' + (10 + parseInt('10'))); } } From e2daee9a655160e4eeea6dee4ceddfe0049ebacf Mon Sep 17 00:00:00 2001 From: Richard van Velzen Date: Sat, 26 Oct 2013 18:44:52 +0200 Subject: [PATCH 2/2] Fix RHS concat (raised in #330) When attempting to concat the left-side of the rhs, make sure the rhs is a string. --- lib/compress.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/compress.js b/lib/compress.js index 121e312a..13ae7c70 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -2067,7 +2067,8 @@ merge(Compressor.prototype, { && self.left.right instanceof AST_Constant && self.right instanceof AST_Binary && self.right.operator == "+" - && self.right.left instanceof AST_Constant) { + && self.right.left instanceof AST_Constant + && self.right.is_string(compressor)) { self = make_node(AST_Binary, self, { operator: "+", left: make_node(AST_Binary, self.left, {