Last active
May 3, 2018 11:40
-
-
Save bofrede/3b9fcdf80b3cfbf848981e845a97aa61 to your computer and use it in GitHub Desktop.
Disable all styles in a @supports rule.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function disable_support(supports_condition) { | |
for (var si = 0; si < document.styleSheets.length; si++) { | |
window.console.log("Looking in " + document.styleSheets[si].href); | |
var rules = document.styleSheets[si].cssRules; | |
for(var i = 0; i < rules.length; i++) { | |
if (rules[i].type === 12 && rules[i].conditionText.match(supports_condition)) { | |
window.console.log("Removing style index " + i); | |
document.styleSheets[0].deleteRule(i); | |
} | |
} | |
} | |
} | |
// To disable rules inside: @supports (display:grid) { | |
function disable_grid_support() { | |
disable_support("(\s*display\s*:\s*grid\s*)"); | |
} | |
// To disable rules inside: @supports (display:flex) { | |
function disable_flex_support() { | |
disable_support("(\s*display\s*:\s*flex\s*)"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment