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

Examples: remove addEventListener third parameter #21100

Closed
marcofugaro opened this issue Jan 17, 2021 · 2 comments · Fixed by #21110
Closed

Examples: remove addEventListener third parameter #21100

marcofugaro opened this issue Jan 17, 2021 · 2 comments · Fixed by #21110

Comments

@marcofugaro
Copy link
Contributor

Is your feature request related to a problem? Please describe.

In examples, you may find event listeners like this:

window.addEventListener( 'resize', onWindowResize, false );

The third parameter, the useCapture parameter, is already false by default.
This confuses newcomers, also combined with the fact that event capturing is a not so easy concept to grasp.

This pattern comes from around 2012, when you needed to define the third parameter explicitly.

image

Nowadays browsers, already default the parameter to false, so it can safely be omitted.

Reference: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener

Describe the solution you'd like

Instead set:

window.addEventListener( 'resize', onWindowResize );

I can contribute with some PRs if we decide to go forward with this change.

@mrdoob
Copy link
Owner

mrdoob commented Jan 17, 2021

I can contribute with some PRs if we decide to go forward with this change.

Sounds good to me 👍

@Mugen87
Copy link
Collaborator

Mugen87 commented Jan 17, 2021

This confuses newcomers, also combined with the fact that event capturing is a not so easy concept to grasp.

Indeed. It's better to not confront the user with this topic by just removing the arguments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants