Skip to content

Instantly share code, notes, and snippets.

@wesbos
Last active August 11, 2021 14:23
Show Gist options
  • Star 20 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wesbos/8b9a22adc1f60336a699 to your computer and use it in GitHub Desktop.
Save wesbos/8b9a22adc1f60336a699 to your computer and use it in GitHub Desktop.
Test for CSS Variables
function testCSSVariables() {
var color = 'rgb(255, 198, 0)';
var el = document.createElement('span');
el.style.setProperty('--color', color);
el.style.setProperty('background', 'var(--color)');
document.body.appendChild(el);
var styles = getComputedStyle(el);
var doesSupport = styles.backgroundColor === color;
document.body.removeChild(el);
return doesSupport;
}
testCSSVariables();
@OutThisLife
Copy link

window.CSS.supports still fails in Saf 😆

@abhinavsingi
Copy link

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