This issue summary is mostly copied from #2031097-1: Respondjs causes navbar js error in firebug/chrome
window.matchMedia and the MediaQueryList object that it returns have a specific interface.
https://developer.mozilla.org/en-US/docs/Web/API/Window.matchMedia
https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList
The polyfill included in the respond.min.js file in the respondjs module itself includes a polyfill of window.matchMedia but the interface is incomplete. It returns an object literal with the matches and media properties, but without the listener methods.
And because respondjs is loading its files very early in the document, modules that might polyfill window.matchMedia instead rely on this implementation.
Respondjs should therefore include a polyfill with a complete interface.
In Drupal 8 we based our polyfill on Paul Irish's polyfill as well, with some extra specialness to avoid the setTimeout polling that his does to look for viewport dimension changes.
http://drupalcode.org/project/drupal.git/blob/HEAD:/core/misc/matchmedia.js
Comments
Comment #1
ruplI thought this would be really straightforward and almost updated the module with upstream without testing, but a quick look at respond.src.js doesn't seem to indicate it includes matchMedia event listeners.
I assume the version checked into D8 HEAD is tested well. Should I just include that instead?
I'm also considering adding a configuration option to remove the bundled matchMedia, so the module ships with two builds and advanced devs can disable this incomplete implementation of matchMedia when necessary (given that my primary upstream lib, respond.js, isn't shipping the "full" matchMedia).
What are your thoughts?
Comment #2
astonvictor commentedD7 reached its EOL back in January 2025, and there is no active release for D7 for this module anymore.
Development or support is not planned for D7. All D7-related issues are marked as outdated in a bunch.