Skip to content
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

inline async function in v-on handler #4568

Closed
lidlanca opened this issue Sep 12, 2021 · 0 comments · Fixed by #4569
Closed

inline async function in v-on handler #4568

lidlanca opened this issue Sep 12, 2021 · 0 comments · Fixed by #4569
Labels
🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. 🐞 bug Something isn't working scope: compiler

Comments

@lidlanca
Copy link
Contributor

Version

3.2.11

Reproduction link

sfc playground repro

Steps to reproduce

see sfc playground link

What is expected?

should work:

@click="async function(){}"
@click="async ()=>{ }"

like:

@click="function(){}"
@click="()=>{}"

What is actually happening?

async keyword prevent detection of inline handler, and wrap it as an expression.

  <button @click="async ()=> stuff() ">
    non callable
  </button>
 _createElementVNode("button", {
      onClick: _cache[0] || (_cache[0] = $event => (async ()=> stuff() ))
    }, " non callable "),

notes

as seen in case 3,4 in the repro link, there is an unintentional behavior that fixes the handler, by using ( ) to wrap an async arrow function.
@click="(async ()=>{ await stuff() })"
it works with ()=>{} but not with function

@lidlanca lidlanca changed the title async function in v-on handler inline async function in v-on handler Sep 12, 2021
@LinusBorg LinusBorg added scope: compiler 🐞 bug Something isn't working 🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. labels Sep 14, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Oct 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. 🐞 bug Something isn't working scope: compiler
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants