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

Use addEventListener when possible. #337

Open
gojefferson opened this issue Sep 28, 2020 · 3 comments
Open

Use addEventListener when possible. #337

gojefferson opened this issue Sep 28, 2020 · 3 comments

Comments

@gojefferson
Copy link

gojefferson commented Sep 28, 2020

matcher. addListener is deprecated, and my testing shows that it does not work on the iPad version of Chrome. There are probably other browsers where ember-responsive is also broken for the same reason.

I've submitted a PR to fix this issue: #336.

@gojefferson
Copy link
Author

Bump on this. Please consider merging the #336.

@edflips
Copy link

edflips commented May 12, 2022

I would very much like to see this PR merged

@tcjr
Copy link

tcjr commented Dec 14, 2022

This should definitely get merged.

The W3C spec says this:

Note: This specification initially had a custom callback mechanism with addListener() and removeListener(), and the callback was invoked with the associated media query list as argument. Now the normal event mechanism is used instead. For backwards compatibility, the addListener() and removeListener() methods are basically aliases for addEventListener() and removeEventListener(), respectively, and the change event masquerades as a MediaQueryList.

And the Mozilla docs on MediaQueryList says this about addListener:

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; ... Be aware that this feature may cease to work at any time.

I just verified that all the existing tests already pass using this code since it checks for addEventListener first. Browsers will likely stop supporting the legacy addListener.

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

3 participants