jalmenarez / minify

Automatically exported from code.google.com/p/minify
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Problem with increment operator #15

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a js file with this line: var i = 0, string = 'foo' + ++i;
2. Minify the file
3. The file is minified as: var i=0,string='foo'+++i;

This causes an "invalid increment operand" error

Thanks for a great tool!

Original issue reported on code.google.com by simon.w...@gmail.com on 24 Aug 2007 at 9:05

GoogleCodeExporter commented 9 years ago
JSMin, which Minify uses to compress JS files, works best with JavaScript that 
passes
a JSLint examination. Ambiguous increment operators like the one in that line 
are
generally considered unwise since they're guaranteed break when whitespace is 
removed.

I recommend changing that line to: var i = 0, string = 'foo' + (i += 1);

Original comment by rgr...@gmail.com on 28 Aug 2007 at 5:25