Compare commits

...

2 Commits

Author SHA1 Message Date
Mihai Bazon
39f8a62703 v2.1.9 2012-11-07 13:31:58 +02:00
Mihai Bazon
46be3f2bf1 fix another small regression
we do need parens here: `new (foo.bar().baz)`, but not here: `new foo.bar.baz`
2012-11-07 13:31:43 +02:00
2 changed files with 17 additions and 2 deletions

View File

@@ -470,7 +470,22 @@ function OutputStream(options) {
PARENS(AST_PropAccess, function(output){
var p = output.parent();
return p instanceof AST_New && p.expression === this;
if (p instanceof AST_New && p.expression === this) {
// i.e. new (foo.bar().baz)
//
// if there's one call into this subtree, then we need
// parens around it too, otherwise the call will be
// interpreted as passing the arguments to the upper New
// expression.
try {
this.walk(new TreeWalker(function(node){
if (node instanceof AST_Call) throw p;
}));
} catch(ex) {
if (ex !== p) throw ex;
return true;
}
}
});
PARENS(AST_Call, function(output){

View File

@@ -3,7 +3,7 @@
"description": "JavaScript parser, mangler/compressor and beautifier toolkit",
"homepage": "http://lisperator.net/uglifyjs",
"main": "tools/node.js",
"version": "2.1.8",
"version": "2.1.9",
"engines": { "node" : ">=0.4.0" },
"maintainers": [{
"name": "Mihai Bazon",