Permalink
Browse files

Bug fix: #26

Problem with "+", "++" and whitespace
  • Loading branch information...
1 parent 93dda69 commit 600861b7bc3fa426e3c6c79bd1d7cdcdfb8054a9 @rspivak committed Mar 14, 2012
Showing with 10 additions and 0 deletions.
  1. +3 −0 src/slimit/tests/test_minifier.py
  2. +7 −0 src/slimit/visitors/minvisitor.py
@@ -365,6 +365,9 @@ def assertMinified(self, source, expected):
# https://github.com/rspivak/slimit/issues/25
('for(a?b:c;d;)e=1;', 'for(a?b:c;d;)e=1;'),
+
+ # https://github.com/rspivak/slimit/issues/26
+ ('"begin"+ ++a+"end";', '"begin"+ ++a+"end";'),
]
@@ -164,6 +164,13 @@ def visit_ForIn(self, node):
def visit_BinOp(self, node):
if node.op in ('instanceof', 'in'):
template = '%s %s %s'
+ elif (node.op == '+' and
+ isinstance(node.right, ast.UnaryOp) and
+ node.right.op == '++' and not node.right.postfix
+ ):
+ # make a space between + and ++
+ # https://github.com/rspivak/slimit/issues/26
+ template = '%s%s %s'
else:
template = '%s%s%s'
if getattr(node, '_parens', False):

1 comment on commit 600861b

Thanks, that did the trick! I've opened an issue on one other thing I ran into which may or may not be a bug depending on your point of view.

Please sign in to comment.