eval method

  1. @override
Node eval (Contexts context)
override

Implementation

@override
Node eval(Contexts context) {
  Node          value = this.value;
  List<Node>    rules = this.rules; // TODO: review, List<Ruleset>

  // media stored inside other directive should not bubble over it
  // backpup media bubbling information
  final List<Media> mediaPathBackup = context.mediaPath;
  final List<Media> mediaBlocksBackup = context.mediaBlocks;

  // deleted media bubbling information
  context
      ..mediaPath = <Media>[]
      ..mediaBlocks = <Media>[];

  if (value != null) value = value.eval(context);
  if (rules != null) {
    // assuming that there is only one rule at this point - that is how parser constructs the rule
    rules = <Ruleset>[rules[0].eval(context)];
    (rules[0] as Ruleset).root = true;
  }
  // restore media bubbling information
  context
      ..mediaPath = mediaPathBackup
      ..mediaBlocks = mediaBlocksBackup;

  return AtRule(name, value,
      rules: rules,
      index: index,
      currentFileInfo: currentFileInfo,
      debugInfo: debugInfo,
      visibilityInfo: visibilityInfo(),
      isRooted: isRooted);

//3.0.0 20160714
// AtRule.prototype.eval = function (context) {
//     var mediaPathBackup, mediaBlocksBackup, value = this.value, rules = this.rules;
//
//     //media stored inside other atrule should not bubble over it
//     //backpup media bubbling information
//     mediaPathBackup = context.mediaPath;
//     mediaBlocksBackup = context.mediaBlocks;
//     //deleted media bubbling information
//     context.mediaPath = [];
//     context.mediaBlocks = [];
//
//     if (value) {
//         value = value.eval(context);
//     }
//     if (rules) {
//         // assuming that there is only one rule at this point - that is how parser constructs the rule
//         rules = [rules[0].eval(context)];
//         rules[0].root = true;
//     }
//     //restore media bubbling information
//     context.mediaPath = mediaPathBackup;
//     context.mediaBlocks = mediaBlocksBackup;
//
//     return new AtRule(this.name, value, rules,
//         this.getIndex(), this.fileInfo(), this.debugInfo, this.isRooted, this.visibilityInfo());
// };
}