diff options
author | Mihai Bazon <mihai@bazon.net> | 2014-04-27 21:42:14 +0300 |
---|---|---|
committer | Mihai Bazon <mihai@bazon.net> | 2014-04-27 21:42:14 +0300 |
commit | 7bf59b5bcd4fb477ce7ea60aaa29ea89b865a955 (patch) | |
tree | 38e311978bdb6613299bf536866a9689985abcec | |
parent | 025f3e9596e336ed4367d8621c920a236d6e4c17 (diff) | |
download | tracifyjs-7bf59b5bcd4fb477ce7ea60aaa29ea89b865a955.tar.gz tracifyjs-7bf59b5bcd4fb477ce7ea60aaa29ea89b865a955.zip |
Actually, even better. #475
- also handle x = + ++y, x = - --y;
- don't use parens, a space suffices.
-rw-r--r-- | lib/output.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/output.js b/lib/output.js index 26f230af..b9637929 100644 --- a/lib/output.js +++ b/lib/output.js @@ -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){ |