better inversion test

This commit is contained in:
Heydon Pickering 2017-08-24 16:29:54 +01:00
parent 54abe01d97
commit 718fd3e67a
3 changed files with 19 additions and 3 deletions

View File

@ -96,11 +96,19 @@
/* Switch and persist theme */ /* Switch and persist theme */
(function () { (function () {
function CSSSupported (property, value) {
var prop = property + ':',
el = document.createElement('test'),
mStyle = el.style;
el.style.cssText = prop + value;
return mStyle[property];
}
var checkbox = document.getElementById('themer'); var checkbox = document.getElementById('themer');
var inverter = document.getElementById('inverter'); var inverter = document.getElementById('inverter');
function darkTheme(media) { function darkTheme(media) {
if (!('filter' in document.body.style)) { if (!CSSSupported('filter', 'invert(100%)')) {
checkbox.parentNode.hidden = true; checkbox.parentNode.hidden = true;
return; return;
} }

File diff suppressed because one or more lines are too long

View File

@ -96,11 +96,19 @@
/* Switch and persist theme */ /* Switch and persist theme */
(function () { (function () {
function CSSSupported (property, value) {
var prop = property + ':',
el = document.createElement('test'),
mStyle = el.style;
el.style.cssText = prop + value;
return mStyle[property];
}
var checkbox = document.getElementById('themer'); var checkbox = document.getElementById('themer');
var inverter = document.getElementById('inverter'); var inverter = document.getElementById('inverter');
function darkTheme(media) { function darkTheme(media) {
if (!('filter' in document.body.style)) { if (!CSSSupported('filter', 'invert(100%)')) {
checkbox.parentNode.hidden = true; checkbox.parentNode.hidden = true;
return; return;
} }