From bfa0bc98b7b37ec693585b424e86a49f22e149a3 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Fri, 2 Aug 2019 16:47:26 -0400 Subject: [PATCH] preserve async/generator-ness of hoisted function expressions (#3179) --- src/compiler/compile/nodes/shared/Expression.ts | 2 +- test/runtime/samples/event-handler-async/_config.js | 5 +++++ test/runtime/samples/event-handler-async/main.svelte | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 test/runtime/samples/event-handler-async/_config.js create mode 100644 test/runtime/samples/event-handler-async/main.svelte diff --git a/src/compiler/compile/nodes/shared/Expression.ts b/src/compiler/compile/nodes/shared/Expression.ts index 3702800c7ba9..938cd8433fce 100644 --- a/src/compiler/compile/nodes/shared/Expression.ts +++ b/src/compiler/compile/nodes/shared/Expression.ts @@ -363,7 +363,7 @@ export default class Expression { } const fn = deindent` - function ${name}(${args.join(', ')}) ${body} + ${node.async && 'async '}function${node.generator && '*'} ${name}(${args.join(', ')}) ${body} `; if (dependencies.size === 0 && contextual_dependencies.size === 0) { diff --git a/test/runtime/samples/event-handler-async/_config.js b/test/runtime/samples/event-handler-async/_config.js new file mode 100644 index 000000000000..fab4d998b605 --- /dev/null +++ b/test/runtime/samples/event-handler-async/_config.js @@ -0,0 +1,5 @@ +export default { + html: ` + + `, +}; diff --git a/test/runtime/samples/event-handler-async/main.svelte b/test/runtime/samples/event-handler-async/main.svelte new file mode 100644 index 000000000000..b22a6af92ed7 --- /dev/null +++ b/test/runtime/samples/event-handler-async/main.svelte @@ -0,0 +1 @@ +