visitSelectorGroup method

  1. @override
void visitSelectorGroup(
  1. SelectorGroup node
)
override

Implementation

@override
void visitSelectorGroup(SelectorGroup node) {
  for (var selectorsIndex = 0;
      selectorsIndex < node.selectors.length;
      selectorsIndex++) {
    var selectors = node.selectors[selectorsIndex];
    var isLastNone = false;
    var selectorName = '';
    for (var index = 0;
        index < selectors.simpleSelectorSequences.length;
        index++) {
      var simpleSeq = selectors.simpleSelectorSequences[index];
      var namePart = simpleSeq.simpleSelector.toString();
      selectorName = (isLastNone) ? (selectorName + namePart) : namePart;
      var matches = _allExtends.inherits[selectorName];
      if (matches != null) {
        for (var match in matches) {
          // Create a new group.
          var newSelectors = selectors.clone();
          var newSeq = match.selectors[0].clone();
          if (isLastNone) {
            // Add the inherited selector.
            node.selectors.add(newSeq);
          } else {
            // Replace the selector sequence to the left of the pseudo class
            // or pseudo element.

            // Make new selector seq combinator the same as the original.
            var orgCombinator =
                newSelectors.simpleSelectorSequences[index].combinator;
            newSeq.simpleSelectorSequences[0].combinator = orgCombinator;

            newSelectors.simpleSelectorSequences.replaceRange(
                index, index + 1, newSeq.simpleSelectorSequences);
            node.selectors.add(newSelectors);
          }
          isLastNone = false;
        }
      } else {
        isLastNone = simpleSeq.isCombinatorNone;
      }
    }
  }
  super.visitSelectorGroup(node);
}