Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


matchMedia.addListener doesn't fire when media query transitions from matched to unmatched #27

WickyNilliams opened this Issue · 2 comments

1 participant

Nick Williams
Nick Williams

The addListener polyfill does not work exactly as one would expect.

If the media query transitions from an unmatched to a matched state, the callback is fired. If the query transitions from a matched state to an unmatched state, the callback is not triggered.

Here's a fiddle to demonstrate the issue:

Of course the above should be tested in IE9 or something. Alternatively, this version I've just removed the guard clauses around the polyfills so it should be demonstrable in any browser:

In simple terms the following code will never be reached:

matchMedia("screen and (min-width:1px)").addListener(function(mql) {
   if(!mql.matches) {
      alert("you ain't seen me, right?!");
Nick Williams

See pull request for fix, will close this for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.