Async handlers don't work if they begin with let
/const
or an if
statement
#3118
Replies: 4 comments 8 replies
-
I was able to side step the bug by wrapping my own expression in an async function and calling it immediately. <button @click="(async () => { ... })()"></button> |
Beta Was this translation helpful? Give feedback.
-
This seems like it should be a simple PR to do, assuming there isn't any threads that pull off. |
Beta Was this translation helpful? Give feedback.
-
I don't understand the |
Beta Was this translation helpful? Give feedback.
-
It looks like the issue is caused by wrapping the expression for safe right hand side evaluation:
alpine/packages/alpinejs/src/evaluator.js
Lines 68 to 77 in 4df4e4f
On line 76, if the above conditions return true, the expression gets wrapped in
(() => ...)()
but that wrapping function is not async, and so anyawait
calls will cause a syntax error.Beta Was this translation helpful? Give feedback.
All reactions