Skip to content

Doesn't work in Safari <13 #8

Description

@nickmcmillan

First up, thanks for making this package!

I've discovered that it doesn't work in Safari 13 (and probably below): [Error] TypeError: mq.addEventListener is not a function.

Safari 13 uses an older, outdated syntax: mq.addListener(handleChange);
Whereas modern browsers use the later spec mq.addEventListener('change', handleChange);
(https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList/addListener)

You could give this a shot instead (although I haven't tested it):

try {
  mq.addEventListener('change', handleChange);
} catch (err) {
  // Safari
  mq.addListener(handleChange);
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions