Allow @at-root with selectors.

This commit is contained in:
Natalie Weizenbaum 2016-10-19 21:17:57 -07:00
parent 95508b2713
commit 9b05b1c24e
2 changed files with 13 additions and 5 deletions

View File

@ -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;
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.

View File

@ -178,6 +178,8 @@ class _PerformVisitor
///
/// Otherwise, this leaves [nodes] as-is and returns [_root].
CssParentNode _trimIncluded(List<CssParentNode> nodes) {
if (nodes.isEmpty) return _root;
var parent = _parent;
int innermostContiguous;
var i = 0;