rugk / website-dark-mode-switcher

This is a (Firefox) add-on (WebExtension) that lets you invert the website's color scheme by inverting/changing the prefers-color-scheme media feature of CSS.
https://addons.mozilla.org/firefox/addon/dark-mode-website-switcher/?src=external-github-top
Other
58 stars 4 forks source link

matchMediaOverwrite should check parameter types #13

Closed rugk closed 3 years ago

rugk commented 5 years ago

Bug description

If an invalid type is passed, we can directly ignore it and forward it to the real query.

Steps to reproduce

  1. Modernizr v2.8.3 passes in the following object as a media query:
    > Foundation.media_queries.small
    Object { selector: ".foundation-mq-small", query: "" }

Actual behavior

The add-on throws an exception: TypeError: mediaQueryString.includes is not a function in getColorTypeFromMediaQuery, because it expects a string there.

Expected behavior

ignore invalid parameters and pass it to the original function

System

Operating system and version: Fedora 30 Browser and version: Firefox 68 Add-on version: latest

Possible solution

check parameter type