-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Remove useless return from eventProxy #2026
Remove useless return from eventProxy #2026
Conversation
Although it is bad practise (in my opinion) it is allowed to prevent default browser behaviour with a return false: https://stackoverflow.com/a/128966 For compatibility reasons I’d vote to keep the return |
Hey @jridgewell so with @sventschui addressing the compatibility reason, I think it's fair enough to consider this as a no-go. Compatibility is a big reason people do use Thank you so much for looking into this! 🙇 |
@cristianbote: Note that no browsers respect the return value. |
Good point, I'll reopen it until we've checked/verified that against our current browser target 👍 |
Hey @jridgewell thanks for clarifying that and also @marvinhagemeister for reopening this 😄! So, the takeaway are these:
<form onsubmit="return false">
<input type="submit" value="click" />
</form>
form.addEventListener('submit', e => { e.returnValue = false; }); So the return does get respected by the browsers if you set the listener as a property. Since we're basically never adding the events listeners as properties, I think we can remove the return statement. Thanks for pointing it out and sorry it tooks us a bit of back and forth. Really appreciate the effort! 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that with the way we're handling event listeners makes total sense to remove the return value for the eventProxy
since it's not gonna be taken into account.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minus bytes 🎉 great spot!
@cristianbote Awesome, thank you so much for getting to the bottom of this 🙌 And of course thank you so much @jridgewell for making a PR 🎉 You rock 💯 |
Thanks for investigating @cristianbote |
I don't think there's any event handler that expects a return value, so I don't think this is needed.