parseCSSStylesheet method

dynamic parseCSSStylesheet(
  1. dynamic node
)

Implementation

parseCSSStylesheet(node) {
  if (node.sheet == null ||
      node.sheet.cssRules == null ||
      node.sheet.cssRules.length == 0) {
    return;
  }

  for (var i = 0; i < node.sheet.cssRules.length; i++) {
    var stylesheet = node.sheet.cssRules[i];

    if (stylesheet.type != 1) continue;

    RegExp _reg = RegExp(r",", multiLine: true);
    var selectorList =
        stylesheet.selectorText.split(_reg).map((i) => i.trim()).toList();

    // var selectorList = stylesheet.selectorText
    // 	.split( /,/gm )
    // 	.filter( Boolean )
    // 	.map( i => i.trim() );

    for (var j = 0; j < selectorList.length; j++) {
      var _sj = selectorList[j];

      if (stylesheets[_sj] == null) {
        stylesheets[_sj] = {};
      }
      stylesheets[_sj].addAll(stylesheet.style);
      // stylesheets[ selectorList[ j ] ] = Object.assign(
      // 	stylesheets[ selectorList[ j ] ] || {},
      // 	stylesheet.style
      // );

    }
  }
}