diff options
author | Anthony Van de Gejuchte <anthonyvdgent@gmail.com> | 2016-06-07 01:33:13 +0200 |
---|---|---|
committer | Richard van Velzen <rvanvelzen@experty.com> | 2016-06-08 19:45:21 +0200 |
commit | 8287ef67810f2332459fa157b26e556f55b36b98 (patch) | |
tree | 1cc5ba4b10a9640971d36b3dc67091510ca9d15d /lib | |
parent | 5cb5305cf3a4dc075461630d5edd81cbfd04b9fc (diff) | |
download | tracifyjs-8287ef67810f2332459fa157b26e556f55b36b98.tar.gz tracifyjs-8287ef67810f2332459fa157b26e556f55b36b98.zip |
Fix uglify attempting to rewrite invalid new expressions
Diffstat (limited to 'lib')
-rw-r--r-- | lib/output.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/output.js b/lib/output.js index f8787582..f5ca0261 100644 --- a/lib/output.js +++ b/lib/output.js @@ -515,7 +515,8 @@ function OutputStream(options) { PARENS([ AST_Unary, AST_Undefined ], function(output){ var p = output.parent(); - return p instanceof AST_PropAccess && p.expression === this; + return p instanceof AST_PropAccess && p.expression === this + || p instanceof AST_New; }); PARENS(AST_Seq, function(output){ @@ -1283,7 +1284,12 @@ function OutputStream(options) { // self should be AST_New. decide if we want to show parens or not. function no_constructor_parens(self, output) { - return self.args.length == 0 && !output.option("beautify"); + return self.args.length == 0 && !output.option("beautify") || + !(self.expression instanceof AST_SymbolRef || + self.expression instanceof AST_Call || + self.expression instanceof AST_Function || + self.expression instanceof AST_Assign + ); }; function best_of(a) { |