Created
March 27, 2011 09:42
-
-
Save gdotdesign/889088 to your computer and use it in GitHub Desktop.
Get CSS properties (by rule) from Stylesheets into an object with MooTools.
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
( -> | |
selectors = {} | |
Array.from(document.styleSheets).each (stylesheet) -> | |
try | |
if stylesheet.cssRules? | |
Array.from(stylesheet.cssRules).each (rule) -> | |
selectors[rule.selectorText] = {} | |
Array.from(rule.style).each (style) -> | |
selectors[rule.selectorText][style] = rule.style.getPropertyValue(style) | |
selectors | |
)() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The syntax doesn't appear to be valid and even with modification, will fail fatally for styles without a selectorText such as @font-face and @Keyframes