visitAtRuleWithBody method

Node visitAtRuleWithBody (AtRule atRuleNode, VisitArgs visitArgs)

Implementation

Node visitAtRuleWithBody(AtRule atRuleNode, VisitArgs visitArgs) {
  // if there is only one nested ruleset and that one has no path, then it is
  // just fake ruleset
  bool hasFakeRuleset(AtRule directiveNode) {
    final List<Ruleset> bodyRules = directiveNode.rules;
    return (bodyRules.length == 1) &&
        (bodyRules.first.paths?.isEmpty ?? true);
  }

  List<Node> getBodyRules(AtRule directiveNode) {
    final List<Ruleset> nodeRules = directiveNode.rules;
    return (hasFakeRuleset(directiveNode)) ? nodeRules[0].rules : nodeRules;
  }

  // it is still true that it is only one ruleset in array
  // this is last such moment
  // process childs
  final List<Node> originalRules = getBodyRules(atRuleNode);
  atRuleNode.accept(_visitor);
  visitArgs.visitDeeper = false;

  if (!utils.isEmpty(atRuleNode)) mergeRules(atRuleNode.rules[0].rules);
  return utils.resolveVisibility(atRuleNode, originalRules);

//2.8.0 20160702
// visitAtRuleWithBody: function(atRuleNode, visitArgs) {
//     //if there is only one nested ruleset and that one has no path, then it is
//     //just fake ruleset
//     function hasFakeRuleset(atRuleNode) {
//         var bodyRules = atRuleNode.rules;
//         return bodyRules.length === 1 && (!bodyRules[0].paths || bodyRules[0].paths.length === 0);
//     }
//     function getBodyRules(atRuleNode) {
//         var nodeRules = atRuleNode.rules;
//         if (hasFakeRuleset(atRuleNode)) {
//             return nodeRules[0].rules;
//         }
//
//         return nodeRules;
//     }
//     //it is still true that it is only one ruleset in array
//     //this is last such moment
//     //process childs
//     var originalRules = getBodyRules(atRuleNode);
//     atRuleNode.accept(this._visitor);
//     visitArgs.visitDeeper = false;
//
//     if (!this.utils.isEmpty(atRuleNode)) {
//         this._mergeRules(atRuleNode.rules[0].rules);
//     }
//
//     return this.utils.resolveVisibility(atRuleNode, originalRules);
// },
}