0

Here's the snippet that fails with "invalid argument" in IE10. Works for Chrome, FF but fails for IE. I am just debugging a js issue and came across this. I dont have any prior knowledge about matchMedia or nor i am a CSS expert. Please excuse my ignorance if any.

win.matchMedia("")
airboss
  • 1,767
  • 3
  • 16
  • 21

1 Answers1

0

I just encountered this, as well. This is inconsistent behavior in IE10-11. My solution was to implement method in my app that first checks for an empty string before invoking matchMedia.matches() ... depending on context you might do something like:

if(meqia_query === "" || matchMedia.matches(media_query)) {
  // do your thing
}

or

function myMatchMedia(media_query) {
  return (meqia_query === "" || matchMedia.matches(media_query));
}
sstrudeau
  • 81
  • 1
  • 1
  • 6