-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
fix: set matchMedia on window to fix issue on IE11, fixes #11358 #11393
Conversation
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.
https://github.com/paulirish/matchMedia.js/blob/cd9df4c529a3c5c95c6d66b77bb7cc3d2419c460/matchMedia.js#L3 is a polyfill that will often be explicitely imported in the project. This is not the case with the embed version inside Foundation. Some could consider this as an undisired and dangerous side-effect, and that this matchMedia
should only be used within the Foundation scope without affecting window
.
If I understand the issue correctly, renaming matchMedia
to _matchMedia
would work too without introducing any side-effect, right ?
We could use the opportunity to update this polyfill to the latest version 😉 |
Why would you do that? A polyfill is meant to directly polyfill the window object, it is now correct in the upstream version but not ours ;-) This polyfills the native matchMedia. |
It just polyfills / sets it if it is not yet available on the window object. |
Does this polyfill perfectly reproduce the native |
It should. It is only used if the browser does not support it. https://caniuse.com/#feat=matchmedia It should still work after these years. I trust @paulirish There are not many polyfills, see https://github.com/search?o=desc&q=matchmedia&s=stars&type=Repositories and https://github.com/Financial-Times/polyfill-service/tree/master/packages/polyfill-library/polyfills/matchMedia |
I still don't understand why Foundation is forcing this polyfill on users. Some sites may only be targeting evergreen browsers that already support this natively, in which case this polyfill adds unnecessary bloat to the JavaScript file. And I agree with @ncoden about the possibility of a conflict with other polyfills (not to mention that in this case you'd shipping 2 polyfills to do the same job... more unnecessary code bloat users will have to download). The Foundation installation guide should mention that a polyfill is required for older versions of IE should the user want to support them, but it should put the onus on the developer to install the polyfill themselves separate from Foundation. |
Polyfills are only applied if the polyfilled feature is not supported so this is not the case. |
And it is not much code ;-) |
Polyfills may be ignored during execution but they are still bloating the Javascript file. |
Also, the browsers that require this polyfill are so ancient and have such a small percentage of market share that it makes no sense to ship this polyfill. IE11 supports this natively and has ~1.9% market share... older IEs that might need this polyfill have ~0.1% market share... at what point do you drop support for older IEs? |
@kb3eua For now, Foundation support IE >= 9 (unless for flex features). It is already planned to deprecate IE 9/10 in future versions, but keep in mind that Foundation is known for its very good browser support and often used for it. |
This is totally different in different countries. |
I know but this is not much compared to the rest. We can also apply a patch using patch-package to remove the code / polyfill ;-) |
It works, but we should not rely on it as package maintainers, this is not a "healthy" and maintainable solution in the long term for our users. |
Sure, this is why I proposed the polyfill-service and then drop internal polyfills ;-) |
…-fix-ie11 for v6.5.0 e7554d6 fix: set matchMedia on window to fix issue on IE11, fixes #11358 1a36a44 chore: update MatchMedia polyfill to v0.3.1 Co-Authored-By: Nicolas Coden <[email protected]> Signed-off-by: Nicolas Coden <[email protected]>
Description
This fixes an issue in IE11 with a conflict between window.matchMedia and matchMedia.
Motivation and Context
Screenshots (if appropriate):
Types of changes
functionality to change)
Checklist (all required):
develop
ordevelop-v...
).