Fix printing of childless at-rules.

This commit is contained in:
Natalie Weizenbaum 2016-08-26 22:49:09 -07:00 committed by Natalie Weizenbaum
parent 0498e8a95c
commit 64c2453a35
3 changed files with 13 additions and 3 deletions

View File

@ -13,13 +13,21 @@ class CssAtRule extends CssParentNode {
final CssValue<String> value;
final bool isChildless;
final FileSpan span;
CssAtRule(this.name, {this.value, this.span});
CssAtRule(this.name, {bool childless: false, this.value, this.span})
: isChildless = childless;
/*=T*/ accept/*<T>*/(CssVisitor/*<T>*/ visitor) =>
visitor.visitAtRule(this);
void addChild(CssNode child) {
assert(!isChildless);
super.addChild(child);
}
String toString() {
var buffer = new StringBuffer("@$name");
if (value != null) buffer.write(" $value");

View File

@ -101,7 +101,9 @@ class PerformVisitor extends StatementVisitor
: _interpolationToValue(node.value, trim: true);
if (node.children == null) {
_parent.addChild(new CssAtRule(node.name, value: value, span: node.span));
_parent.addChild(new CssAtRule(node.name,
childless: true, value: value, span: node.span));
return;
}
_withParent(new CssAtRule(node.name, value: value, span: node.span), () {

View File

@ -75,7 +75,7 @@ class _SerializeCssVisitor extends CssVisitor {
_buffer.write(node.value.value);
}
if (node.children == null) {
if (node.isChildless) {
_buffer.writeCharCode($semicolon);
} else {
_buffer.writeCharCode($space);