dart-sass/lib/src/ast/css/at_rule.dart

32 lines
969 B
Dart
Raw Normal View History

2016-06-10 01:37:54 +02:00
// Copyright 2016 Google Inc. Use of this source code is governed by an
// MIT-style license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
import 'package:source_span/source_span.dart';
import '../../visitor/css.dart';
import 'node.dart';
import 'value.dart';
class CssAtRule implements CssNode {
final String name;
final CssValue<String> value;
final List<CssNode> children;
final FileSpan span;
// TODO: validate that children contains only at-rule and declaration nodes?
CssAtRule(this.name, {this.value, Iterable<CssNode> children, this.span})
: children = children == null ? null : new List.unmodifiable(children);
/*=T*/ accept/*<T>*/(CssVisitor/*<T>*/ visitor) =>
visitor.visitAtRule(this);
String toString() {
var buffer = new StringBuffer("@$name");
if (value != null) buffer.write(" $value");
return children == null ? "$buffer;" : "$buffer {${children.join(" ")}}";
}
}