diff --git a/lib/src/parse/stylesheet.dart b/lib/src/parse/stylesheet.dart index b1d6c36b..dc4a62cc 100644 --- a/lib/src/parse/stylesheet.dart +++ b/lib/src/parse/stylesheet.dart @@ -425,11 +425,17 @@ abstract class StylesheetParser extends Parser { /// /// [start] should point before the `@`. AtRootRule _atRootRule(LineScannerState start) { - var next = scanner.peekChar(); - var query = next == $hash || next == $lparen ? _queryExpression() : null; - whitespace(); - return new AtRootRule(children(_ruleChild), scanner.spanFrom(start), - query: query); + if (scanner.peekChar() == $lparen) { + var query = _queryExpression(); + whitespace(); + return new AtRootRule(children(_ruleChild), scanner.spanFrom(start), + query: query); + } else if (lookingAtChildren()) { + return new AtRootRule(children(_ruleChild), scanner.spanFrom(start)); + } else { + var child = _styleRule(); + return new AtRootRule([child], scanner.spanFrom(start)); + } } /// Consumes a `@content` rule. diff --git a/lib/src/visitor/perform.dart b/lib/src/visitor/perform.dart index fa0b7952..8608ca20 100644 --- a/lib/src/visitor/perform.dart +++ b/lib/src/visitor/perform.dart @@ -178,6 +178,8 @@ class _PerformVisitor /// /// Otherwise, this leaves [nodes] as-is and returns [_root]. CssParentNode _trimIncluded(List nodes) { + if (nodes.isEmpty) return _root; + var parent = _parent; int innermostContiguous; var i = 0;