From: Mihai Bazon Date: Wed, 6 Feb 2013 09:36:04 +0000 (+0200) Subject: Fix parens for negative numbers X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=de7ec7f1b7e387f933daef7ef035583a8ca8b715;p=UglifyJS.git Fix parens for negative numbers Close #115 --- diff --git a/lib/output.js b/lib/output.js index 27b35fe6..ab9b82b4 100644 --- a/lib/output.js +++ b/lib/output.js @@ -514,6 +514,12 @@ function OutputStream(options) { return true; }); + PARENS(AST_Number, function(output){ + var p = output.parent(); + if (this.getValue() < 0 && p instanceof AST_PropAccess && p.expression === this) + return true; + }); + function assign_and_conditional_paren_rules(output) { var p = output.parent(); // !(a = false) → true @@ -942,7 +948,7 @@ function OutputStream(options) { DEFPRINT(AST_Dot, function(self, output){ var expr = self.expression; expr.print(output); - if (expr instanceof AST_Number) { + if (expr instanceof AST_Number && expr.getValue() >= 0) { if (!/[xa-f.]/i.test(output.last())) { output.print("."); }