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

event modifier breaks if handler is undefined #9865

Closed
theoephraim opened this issue Dec 19, 2023 · 3 comments · Fixed by #9866
Closed

event modifier breaks if handler is undefined #9865

theoephraim opened this issue Dec 19, 2023 · 3 comments · Fixed by #9866

Comments

@theoephraim
Copy link

Vue version

3.3.12

Link to minimal reproduction

https://play.vuejs.org/#eNqNUk1PGzEQ/SvGl7QSuxblFi1RWoTU9tBWBYmLL2F3khj8JXu8RFrtf2fsFSGJEOJmz3sz897MDPy793WfgM95E9ugPLIImPxCWmW8C8gGFmDNRrYOzrAZUWfSSts6G5GZuGFXGf8y+wlaO3bvgu7OZl8zpRFTQSpFHwTj9QqBfow124vFMJT0cWwE/UpUWZ+Q9ZVxHegryQmXnIkJfEiIzrJlq1X7VPsAPVgkUrIdrJWFTvLFdcaYgbNGTHRKbcRBa37OMZL2tdrUj9FZsj3k6pK3znilIfz1qMib5HNWkIytyNrz7xLDkOD8Nd5uoX16J/4Ydzkm+b8AEUIPku8xXIUN4ATf3P6BHb33IBlPmtgfgP8hOp2yxon2g/yT7ANeUfurLE/ZzV282SHY+GoqC83MsfAlp4Vef2D9Te5lfVnypB1pitNxVGblT+Y4AcdFqMckdovo41yItrOURktWfagtoLDeiCXRREgWlYGqc2ZJHeuLb6JTEQ/jNURTPQT3TKOlO3AdlTqwn6uUoYcqAN1GyMP5XPOTtCMBJ9iRiNx/P5vxBXr5H20=

Steps to reproduce

Use an event modifier (like .prevent on a click event that has an undefined handler - for example @click.prevent="undefined"

While that may seem silly, something like @click.prevent="myModalRef?.open()" is totally reasonable and can result in the same thing...

What is expected?

no crash. Probably @click.prevent should still prevent default behaviour...

What is actually happening?

page crashes, with error Cannot read properties of undefined (reading '_withMods')

System Info

No response

Any additional comments?

PS - the new issue wizard thing broke.. I got the "Issue Preview" screen, but then it just kept kicking me back to the native "new issue" button on github.

@yyx990803
Copy link
Member

yyx990803 commented Dec 19, 2023

FYI you should just do @click.prevent without a value... there's no need to add an undefined handler.

@theoephraim
Copy link
Author

theoephraim commented Dec 19, 2023

Totally - My issue came from the undefined template ref case. The reproduction given was just easier to show by setting directly to undefined - which obviously makes no sense :)

Thanks so much for the quick fix @yyx990803

@theoephraim
Copy link
Author

Quick question - I just updated my vue version and I'm still seeing the issue (even though I can see it resolved in the playground).

Is that because the code is compiler related and I need to wait for @vitejs/plugin-vue to update to the latest version?

Thanks so much!

@github-actions github-actions bot locked and limited conversation to collaborators Jan 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants