function cssToRules(cssText) { var style = cssTextToStyle(cssText); document.head.appendChild(style); var rules = []; if (style.sheet) { try { rules = style.sheet.cssRules; } catch (e) {} } else { console.warn("sheet not found", style); } style.parentNode.removeChild(style); return rules; }
// Helpers var isValidStyleNode = function (node) { return node instanceof HTMLStyleElement && node.sheet.cssRules.length > 0; }
function withCssRules(cssText, callback) { if (!callback) { return; } var rules; if (cssText.match("@import") && isChrome) { var style = cssTextToStyle(cssText); inFrame(function(doc) { doc.head.appendChild(style.impl); rules = Array.prototype.slice.call(style.sheet.cssRules, 0); callback(rules); }); } else { rules = cssToRules(cssText); callback(rules); } }
function cssToRules(cssText) { var style = cssTextToStyle(cssText); document.head.appendChild(style); var rules = []; if (style.sheet) { try { rules = style.sheet.cssRules; } catch (e) {} } else { console.warn("sheet not found", style); } style.parentNode.removeChild(style); return rules; }
function cssToRules(cssText) { var style = cssTextToStyle(cssText); document.head.appendChild(style); var rules = []; if (style.sheet) { try { rules = style.sheet.cssRules; } catch (e) {} } else { console.warn("sheet not found", style); } style.parentNode.removeChild(style); return rules; }
function withCssRules(cssText, callback) { if (!callback) { return; } var rules; if (cssText.match("@import") && isChrome) { var style = cssTextToStyle(cssText); inFrame(function(doc) { doc.head.appendChild(style.impl); rules = Array.prototype.slice.call(style.sheet.cssRules, 0); callback(rules); }); } else { rules = cssToRules(cssText); callback(rules); } }
function withCssRules(cssText, callback) { if (!callback) { return; } var rules; if (cssText.match("@import") && isChrome) { var style = cssTextToStyle(cssText); inFrame(function(doc) { doc.head.appendChild(style.impl); rules = Array.prototype.slice.call(style.sheet.cssRules, 0); callback(rules); }); } else { rules = cssToRules(cssText); callback(rules); } }