Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bug fix: #26

Problem with "+", "++" and whitespace
  • Loading branch information...
commit 600861b7bc3fa426e3c6c79bd1d7cdcdfb8054a9 1 parent 93dda69
@rspivak authored
View
3  src/slimit/tests/test_minifier.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";'),
]
View
7 src/slimit/visitors/minvisitor.py
@@ -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

@davidkhess

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.
Something went wrong with that request. Please try again.