Actually, even better. #475
- also handle x = + ++y, x = - --y; - don't use parens, a space suffices.
This commit is contained in:
@@ -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){
|
||||
|
||||
Reference in New Issue
Block a user