Actually, even better. #475

- also handle x = + ++y, x = - --y;
- don't use parens, a space suffices.
This commit is contained in:
Mihai Bazon
2014-04-27 21:42:14 +03:00
parent 025f3e9596
commit 7bf59b5bcd

View File

@@ -455,8 +455,7 @@ function OutputStream(options) {
PARENS(AST_Unary, function(output){
var p = output.parent();
return (p instanceof AST_PropAccess && p.expression === this)
|| (p instanceof AST_Unary && p.operator == this.operator);
return p instanceof AST_PropAccess && p.expression === this;
});
PARENS(AST_Seq, function(output){
@@ -997,8 +996,12 @@ function OutputStream(options) {
DEFPRINT(AST_UnaryPrefix, function(self, output){
var op = self.operator;
output.print(op);
if (/^[a-z]/i.test(op))
if (/^[a-z]/i.test(op)
|| (/[+-]$/.test(op)
&& self.expression instanceof AST_UnaryPrefix
&& /^[+-]/.test(self.expression.operator))) {
output.space();
}
self.expression.print(output);
});
DEFPRINT(AST_UnaryPostfix, function(self, output){