implement suggested changeset from @kzc

This commit is contained in:
Fábio Santos 2018-03-09 18:52:53 +00:00
parent e5a0fcdfc6
commit 113a5236bc
2 changed files with 5 additions and 17 deletions

View File

@ -773,6 +773,7 @@ function OutputStream(options) {
|| p instanceof AST_Expansion // [...(a, b)] || p instanceof AST_Expansion // [...(a, b)]
|| p instanceof AST_ForOf && this === p.object // for (e of (foo, bar)) {} || p instanceof AST_ForOf && this === p.object // for (e of (foo, bar)) {}
|| p instanceof AST_Yield // yield (foo, bar) || p instanceof AST_Yield // yield (foo, bar)
|| p instanceof AST_Export // export default (foo, bar)
; ;
}); });
@ -844,7 +845,8 @@ function OutputStream(options) {
PARENS(AST_Call, function(output){ PARENS(AST_Call, function(output){
var p = output.parent(), p1; var p = output.parent(), p1;
if (p instanceof AST_New && p.expression === this) if (p instanceof AST_New && p.expression === this
|| p instanceof AST_Export && p.is_default && this.expression instanceof AST_Function)
return true; return true;
// workaround for Safari bug. // workaround for Safari bug.
@ -1106,20 +1108,6 @@ function OutputStream(options) {
self._do_print(output); self._do_print(output);
}); });
DEFPRINT(AST_Function, function(self, output) {
var parent = output.parent();
var grandparent = output.parent(1);
var is_exported_iife = parent instanceof AST_Call && parent.expression == self &&
grandparent instanceof AST_Export && grandparent.is_default;
if (is_exported_iife) {
output.with_parens(function() {
self._do_print(output);
});
} else {
self._do_print(output);
}
});
DEFPRINT(AST_PrefixedTemplateString, function(self, output) { DEFPRINT(AST_PrefixedTemplateString, function(self, output) {
self.prefix.print(output); self.prefix.print(output);
self.template_string.print(output); self.template_string.print(output);

View File

@ -410,7 +410,7 @@ export_default_anonymous_function_not_call: {
export default function(){}(foo); export default function(){}(foo);
} }
// FIXME: should be `export default function(){};foo;` // FIXME: should be `export default function(){};foo;`
expect_exact: "export default(function(){})(foo);" expect_exact: "export default(function(){}(foo));"
} }
export_default_anonymous_generator_not_call: { export_default_anonymous_generator_not_call: {
@ -449,5 +449,5 @@ issue_2977: {
input: { input: {
export default (function () {})(); export default (function () {})();
} }
expect_exact: "export default(function(){})();" expect_exact: "export default(function(){}());"
} }