Skip to content

Instantly share code, notes, and snippets.

@gdotdesign
Created March 27, 2011 09:42
Show Gist options
  • Save gdotdesign/889088 to your computer and use it in GitHub Desktop.
Save gdotdesign/889088 to your computer and use it in GitHub Desktop.
Get CSS properties (by rule) from Stylesheets into an object with MooTools.
( ->
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
)()
@fusionstream
Copy link

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

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