fix: split space-separated event names in input listeners (@zacharybergin) - #8389
Open
zacharybergin wants to merge 1 commit into
Open
fix: split space-separated event names in input listeners (@zacharybergin)#8389zacharybergin wants to merge 1 commit into
zacharybergin wants to merge 1 commit into
Conversation
addEventListener matches the type argument as a single literal string, so "copy paste" and "select selectstart" registered listeners for events that can never fire. Both are jQuery .on() syntax, which accepts space-separated lists; the DOM API does not. Register each event separately so copy/paste prevention on the words input works as intended.
Member
|
duplicate #8371 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
addEventListener only takes one event name at a time. So "copy paste" and "select selectstart" were not really registering both events.
This meant copy and paste into the words input was never actually being blocked. It looks like the space separated syntax was left over from the jQuery .on() code before the input rewrite in #7119.
I split these into separate listeners so each event should actually be registered correctly.
One thing I noticed is that fixing selectstart also makes the selection blocking work again. It's been broken since #7119. So this is technically a behavior change and not just a bug fix. Let me know if you'd rather I leave that part out.
Also select isn't cancelable so preventDefault() doesn't really do anything for that event.
Closes #8361