Created
March 12, 2010 04:29
-
-
Save harthur/330033 to your computer and use it in GitHub Desktop.
This file contains 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 allStyleSheets(doc) { | |
var stylesheets = []; | |
for(var i = 0; i < doc.styleSheets.length; i++) | |
stylesheets = stylesheets.concat(getStyleSheets(doc.styleSheets[i])); | |
return stylesheets; | |
} | |
function getStyleSheets(stylesheet) { | |
if(!stylesheet) | |
return []; // Firefox protects against @import statement loops | |
var stylesheets = [stylesheet]; | |
var rules = stylesheet.cssRules; | |
for(var i = 0; i < rules.length; i++) { | |
if(rules[i].type == CSSRule.IMPORT_RULE) | |
stylesheets = stylesheets.concat(getStyleSheets(rules[i].styleSheet)); | |
} | |
return stylesheets; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment