fix: support browsers that don't implement 'prefers-contrast' media query
This commit is contained in:
1 parent
1db991aa29
commit
f21814b11e
1 file changed
+9
-3
@@ -14,12 +14,18 @@ const systemPreferencesHOC = function (WrappedComponent) {
|
||||
componentDidMount () {
|
||||
this.preferencesListener = () => this.props.onSetTheme(detectTheme());
|
||||
|
||||
this.highContrastMatchMedia = window.matchMedia(prefersHighContrastQuery);
|
||||
this.highContrastMatchMedia.addEventListener('change', this.preferencesListener);
|
||||
if (window.matchMedia) {
|
||||
this.highContrastMatchMedia = window.matchMedia(prefersHighContrastQuery);
|
||||
if (this.highContrastMatchMedia) {
|
||||
this.highContrastMatchMedia.addEventListener('change', this.preferencesListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount () {
|
||||
this.highContrastMatchMedia.removeEventListener('change', this.preferencesListener);
|
||||
if (this.highContrastMatchMedia) {
|
||||
this.highContrastMatchMedia.removeEventListener('change', this.preferencesListener);
|
||||
}
|
||||
}
|
||||
|
||||
render () {
|
||||
|
||||
Reference in new issue
Block a user