From 12ec31566f6428ec293c7fd75c45cf9a9d36bc39 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Wed, 2 Nov 2016 17:27:17 -0700 Subject: [PATCH] Clean up more newline generation. --- lib/src/visitor/serialize.dart | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/src/visitor/serialize.dart b/lib/src/visitor/serialize.dart index 7a33eb68..7ec5270c 100644 --- a/lib/src/visitor/serialize.dart +++ b/lib/src/visitor/serialize.dart @@ -85,15 +85,18 @@ class _SerializeCssVisitor _quote = quote; void visitStylesheet(CssStylesheet node) { + CssNode previous; for (var i = 0; i < node.children.length; i++) { var child = node.children[i]; if (_isInvisible(child)) continue; - child.accept(this); - if (i != node.children.length - 1) { + if (previous != null) { _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(); _indent(() { + CssNode previous; for (var i = 0; i < children.length; i++) { var child = children[i]; if (_isInvisible(child)) continue; + + if (previous != null) { + _buffer.writeln(); + if (previous.isGroupEnd) _buffer.writeln(); + } + previous = child; + child.accept(this); - _buffer.writeln(); - if (i != children.length - 1 && child.isGroupEnd) _buffer.writeln(); } }); + _buffer.writeln(); _writeIndentation(); _buffer.writeCharCode($rbrace); }