-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support async arrow function for inline event handlers #3179
Comments
The compiler does not appear to be throwing an error, but the generated code is invalid, and the event handler is not labeled as |
diff --git a/src/compiler/compile/nodes/shared/Expression.ts b/src/compiler/compile/nodes/shared/Expression.ts
index 3702800c..938cd843 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) { When created fully or partially hoisted function declarations, this makes sure their async-ness and generator-ness are specified correctly. I don't think there's anything else we need to do for this. |
preserve async/generator-ness of hoisted function expressions
This is fixed in 3.6.11 - https://svelte.dev/repl/6715cdf1e8324c10bc5d4c6e9489bcbf?version=3.6.11 |
It would be nice to have
async
inline event handlers without writing the full function in the<script>
tag like:Currently, the compiler raises the following compile error
REPL Demo
MDN Reference
The text was updated successfully, but these errors were encountered: