Clean up more newline generation.

This commit is contained in:
Natalie Weizenbaum 2016-11-02 17:27:17 -07:00
parent d096be56f8
commit 12ec31566f

View File

@ -85,15 +85,18 @@ class _SerializeCssVisitor
_quote = quote; _quote = quote;
void visitStylesheet(CssStylesheet node) { void visitStylesheet(CssStylesheet node) {
CssNode previous;
for (var i = 0; i < node.children.length; i++) { for (var i = 0; i < node.children.length; i++) {
var child = node.children[i]; var child = node.children[i];
if (_isInvisible(child)) continue; if (_isInvisible(child)) continue;
child.accept(this);
if (i != node.children.length - 1) { if (previous != null) {
_buffer.writeln(); _buffer.writeln();
if (child.isGroupEnd) _buffer.writeln(); if (previous.isGroupEnd) _buffer.writeln();
} }
previous = child;
child.accept(this);
} }
} }
@ -756,14 +759,21 @@ class _SerializeCssVisitor
_buffer.writeln(); _buffer.writeln();
_indent(() { _indent(() {
CssNode previous;
for (var i = 0; i < children.length; i++) { for (var i = 0; i < children.length; i++) {
var child = children[i]; var child = children[i];
if (_isInvisible(child)) continue; if (_isInvisible(child)) continue;
if (previous != null) {
_buffer.writeln();
if (previous.isGroupEnd) _buffer.writeln();
}
previous = child;
child.accept(this); child.accept(this);
_buffer.writeln();
if (i != children.length - 1 && child.isGroupEnd) _buffer.writeln();
} }
}); });
_buffer.writeln();
_writeIndentation(); _writeIndentation();
_buffer.writeCharCode($rbrace); _buffer.writeCharCode($rbrace);
} }