Created
June 24, 2009 22:41
-
-
Save swannodette/135566 to your computer and use it in GitHub Desktop.
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
Fx.CSS.implement({ | |
search: function(selector){ | |
if (Fx.CSS.Cache[selector]) return Fx.CSS.Cache[selector]; | |
var to = {}; | |
function extract(sheet, j){ | |
var href = sheet.href; | |
if (href && href.contains('://') && !href.contains(document.domain)) return; | |
var rules = sheet.rules || sheet.cssRules; | |
Array.each(sheet.imports, extract); | |
Array.each(rules, function(rule, i){ | |
if (rule.styleSheet) extract(rule.styleSheet); | |
if (!rule.style) return; | |
var selectorText = (rule.selectorText) ? rule.selectorText.replace(/^\w+/, function(m){ | |
return m.toLowerCase(); | |
}) : null; | |
if (!selectorText || !selectorText.test('^' + selector + '$')) return; | |
Element.Styles.each(function(value, style){ | |
if (!rule.style[style] || Element.ShortStyles[style]) return; | |
value = String(rule.style[style]); | |
to[style] = (value.test(/^rgb/)) ? value.rgbToHex() : value; | |
}); | |
}); | |
} | |
Array.each(document.styleSheets, extract); | |
return Fx.CSS.Cache[selector] = to; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment