add Safari workaround for await (#2528)

fixes #2344
This commit is contained in:
Alex Lam S.L
2017-11-29 00:20:36 +08:00
committed by GitHub
parent 755e2a62c6
commit aacf760fb4
2 changed files with 31 additions and 1 deletions

View File

@@ -68,6 +68,7 @@ function OutputStream(options) {
preserve_line : false,
quote_keys : false,
quote_style : 0,
safari10 : false,
semicolons : true,
shebang : true,
shorthand : undefined,
@@ -677,7 +678,8 @@ function OutputStream(options) {
PARENS(AST_Await, function(output){
var p = output.parent();
return p instanceof AST_PropAccess && p.expression === this
|| p instanceof AST_Call && p.expression === this;
|| p instanceof AST_Call && p.expression === this
|| output.option("safari10") && p instanceof AST_UnaryPrefix;
});
PARENS(AST_Sequence, function(output){

View File

@@ -293,3 +293,31 @@ async_arrow_iife_negate_iife: {
}
expect_exact: "(async()=>{await fetch()})();(()=>{plain()})();"
}
issue_2344_1: {
beautify = {
safari10: false,
}
input: {
async () => {
+await x;
await y;
return await z;
};
}
expect_exact: "async()=>{+await x;await y;return await z};"
}
issue_2344_2: {
beautify = {
safari10: true,
}
input: {
async () => {
+await x;
await y;
return await z;
};
}
expect_exact: "async()=>{+(await x);await y;return await z};"
}