aboutsummaryrefslogtreecommitdiff
path: root/lib/output.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/output.js')
-rw-r--r--lib/output.js28
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/output.js b/lib/output.js
index 61524239..990fcce4 100644
--- a/lib/output.js
+++ b/lib/output.js
@@ -8,6 +8,7 @@ function OutputStream(options) {
ascii_only : false,
inline_script : false,
width : 80,
+ ie_proof : true,
beautify : true
});
@@ -262,14 +263,14 @@ function OutputStream(options) {
PARENS(AST_Seq, function(output){
var p = output.parent();
- return p instanceof AST_Call // (foo, bar)() —or— foo(1, (2, 3), 4)
- || p instanceof AST_Binary // 1 + (2, 3) + 4 → 7
- || p instanceof AST_VarDef // var a = (1, 2), b = a + a; → b = 4
- || p instanceof AST_Dot // (1, {foo:2}).foo → 2
- || p instanceof AST_Array // [ 1, (2, 3), 4 ] → [ 1, 3, 4 ]
- || p instanceof AST_ObjectProperty // { foo: (1, 2) }.foo → 2
+ return p instanceof AST_Call // (foo, bar)() or foo(1, (2, 3), 4)
+ || p instanceof AST_Binary // 1 + (2, 3) + 4 ==> 7
+ || p instanceof AST_VarDef // var a = (1, 2), b = a + a; ==> b == 4
+ || p instanceof AST_Dot // (1, {foo:2}).foo ==> 2
+ || p instanceof AST_Array // [ 1, (2, 3), 4 ] ==> [ 1, 3, 4 ]
+ || p instanceof AST_ObjectProperty // { foo: (1, 2) }.foo ==> 2
|| p instanceof AST_Conditional /* (false, true) ? (a = 10, b = 20) : (c = 30)
- * → 20 (side effect, set a = 10 and b = 20) */
+ * ==> 20 (side effect, set a := 10 and b := 20) */
;
});
@@ -324,7 +325,7 @@ function OutputStream(options) {
// !(a = false) → true
if (p instanceof AST_Unary)
return true;
- // 1 + (a = 2) + 3 → 3, side effect setting a = 2
+ // 1 + (a = 2) + 3 → 6, side effect setting a = 2
if (p instanceof AST_Binary && !(p instanceof AST_Assign))
return true;
// (a = func)() —or— new (a = Object)()
@@ -529,7 +530,8 @@ function OutputStream(options) {
// adds the block brackets if needed.
if (!self.consequent)
return output.semicolon();
- if (self.consequent instanceof AST_Do) {
+ if (self.consequent instanceof AST_Do
+ && output.option("ie_proof")) {
// https://github.com/mishoo/UglifyJS/issues/#issue/57 IE
// croaks with "syntax error" on code like this: if (foo)
// do ... while(cond); else ... we need block brackets
@@ -546,10 +548,10 @@ function OutputStream(options) {
}
b = b.alternative;
}
- else if (b instanceof AST_While ||
- b instanceof AST_Do ||
- b instanceof AST_For ||
- b instanceof AST_ForIn) {
+ else if (b instanceof AST_While
+ || b instanceof AST_Do
+ || b instanceof AST_For
+ || b instanceof AST_ForIn) {
b = b.body;
}
else break;