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

[BUG] This does not provide the correct parameters for addEventListener on new Chrome versions. "Unable to preventDefault inside passive event listener due to target being treated as passive" #383

Open
douglasg14b opened this issue Jun 6, 2021 · 1 comment

Comments

@douglasg14b
Copy link

douglasg14b commented Jun 6, 2021

The lib is not checking for passive support and providing the correct parameters if it exists. Google has a blog post on this change: (https://developers.google.com/web/updates/2017/01/scrolling-intervention):

The default behavior is for window, document or body elements is: window.addEventListener("touchstart", func, {passive: true} ); unless {passive: false} is passed in explicitly. In this case the lib does not do this.

This means if anything down the road wants to preventDefault() the following exception will be thrown: Unable to preventDefault inside passive event listener due to target being treated as passive

More Info:

image

Related: quasarframework/quasar#9577

@douglasg14b douglasg14b changed the title Just adding this Vue plugin (Not using the directive) breaks mobile tapping for some things like menus in other frameworks This breaks some event handling in other frameworks "Unable to preventDefault inside passive event listener due to target being treated as passive" Jun 6, 2021
@douglasg14b douglasg14b changed the title This breaks some event handling in other frameworks "Unable to preventDefault inside passive event listener due to target being treated as passive" This breaks some event handling in other frameworks on mobile "Unable to preventDefault inside passive event listener due to target being treated as passive" Jun 6, 2021
@douglasg14b douglasg14b changed the title This breaks some event handling in other frameworks on mobile "Unable to preventDefault inside passive event listener due to target being treated as passive" This does not provide the correct parameters for addEventListener on new Chrome versions. "Unable to preventDefault inside passive event listener due to target being treated as passive" Jun 6, 2021
@douglasg14b
Copy link
Author

douglasg14b commented Jun 6, 2021

I have verified that these changes stop this problem from occuring:

srcTarget.addEventListener(event, handler, { capture: false, passive: false });

and

srcTarget.removeEventListener(event, handler, { capture: false, passive: false })

HOWEVER, browser support is limited. Which means before this parameter can be used, support must first be checked, and if it does not exist, the old parameter should be used.

@douglasg14b douglasg14b changed the title This does not provide the correct parameters for addEventListener on new Chrome versions. "Unable to preventDefault inside passive event listener due to target being treated as passive" [BUG] This does not provide the correct parameters for addEventListener on new Chrome versions. "Unable to preventDefault inside passive event listener due to target being treated as passive" Aug 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant