diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2018-08-08 16:15:45 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-08 16:15:45 +0800 |
commit | fc78423f1d9bfa10774a04563e37e130523bf46d (patch) | |
tree | b70264ddd42d8a7b778753c6c0eea8cd98a32f09 /lib/output.js | |
parent | 2a5277b391f11e49306fb5a46f6037763916da4a (diff) | |
download | tracifyjs-fc78423f1d9bfa10774a04563e37e130523bf46d.tar.gz tracifyjs-fc78423f1d9bfa10774a04563e37e130523bf46d.zip |
clean up webkit quirks (#3229)
Diffstat (limited to 'lib/output.js')
-rw-r--r-- | lib/output.js | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/lib/output.js b/lib/output.js index f3feabec..7f7e74df 100644 --- a/lib/output.js +++ b/lib/output.js @@ -694,23 +694,15 @@ function OutputStream(options) { // a function expression needs parens around it when it's provably // the first token to appear in a statement. PARENS(AST_Function, function(output) { - if (!output.has_parens() && first_in_statement(output)) { - return true; - } - + if (!output.has_parens() && first_in_statement(output)) return true; if (output.option('webkit')) { var p = output.parent(); - if (p instanceof AST_PropAccess && p.expression === this) { - return true; - } + if (p instanceof AST_PropAccess && p.expression === this) return true; } - if (output.option('wrap_iife')) { var p = output.parent(); - return p instanceof AST_Call && p.expression === this; + if (p instanceof AST_Call && p.expression === this) return true; } - - return false; }); // same goes for an object literal, because otherwise it would be @@ -784,17 +776,17 @@ function OutputStream(options) { }); PARENS(AST_Call, function(output) { - var p = output.parent(), p1; - if (p instanceof AST_New && p.expression === this) - return true; - - // workaround for Safari bug. + var p = output.parent(); + if (p instanceof AST_New && p.expression === this) return true; // https://bugs.webkit.org/show_bug.cgi?id=123506 - return this.expression instanceof AST_Function - && p instanceof AST_PropAccess - && p.expression === this - && (p1 = output.parent(1)) instanceof AST_Assign - && p1.left === p; + if (output.option('webkit')) { + var g = output.parent(1); + return this.expression instanceof AST_Function + && p instanceof AST_PropAccess + && p.expression === this + && g instanceof AST_Assign + && g.left === p; + } }); PARENS(AST_New, function(output) { |