Last active
December 18, 2015 09:59
-
-
Save ny0m/5764961 to your computer and use it in GitHub Desktop.
Some additions to REM-unit-polyfill to prevent it from cycling through styles enclosed in @media queries in browsers that don't support them.
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
// Test for Media Query support | |
mediaQuery = function() { | |
if (window.matchMedia || window.msMatchMedia) { return true; } | |
return false; | |
} | |
// Remove queries. | |
removeMediaQueries = function(css) { | |
if (!mediaQuery()) { | |
while (css.match(/@media/) !== null) { // If CSS syntax is correct there should always be a "@media" str matching a "}\s*}" string | |
var start = css.match(/@media/).index, | |
end = css.match(/\}\s*\}/); | |
css = css.substring(0, start) + css.substring(end.index + end[0].length); | |
} | |
} | |
return css; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment