Support &1.

This commit is contained in:
Natalie Weizenbaum 2017-01-14 18:27:50 -08:00
parent b695fa6461
commit 015bb0d79f
3 changed files with 17 additions and 3 deletions

View File

@ -22,6 +22,8 @@
* Always parse imports with queries as plain CSS imports.
* Support `&` followed by a non-identifier.
## 1.0.0-alpha.8
* Add the `content-exists()` function.

View File

@ -103,6 +103,20 @@ abstract class Parser {
scanner.error("Expected identifier.");
}
_identifierBody(text, unit: unit);
return text.toString();
}
/// Consumes a chunk of a plain CSS identifier after the name start.
String identifierBody() {
var text = new StringBuffer();
_identifierBody(text);
if (text.isEmpty) scanner.error("expected identifier body.");
return text.toString();
}
/// Like [_identifierBody], but parses the body into the [text] buffer.
void _identifierBody(StringBuffer text, {bool unit: false}) {
while (true) {
var next = scanner.peekChar();
if (next == null) {
@ -120,8 +134,6 @@ abstract class Parser {
break;
}
}
return text.toString();
}
/// Consumes a plain CSS string.

View File

@ -263,7 +263,7 @@ class SelectorParser extends Parser {
/// Consumes a parent selector.
ParentSelector _parentSelector() {
scanner.expectChar($ampersand);
var suffix = lookingAtIdentifierBody() ? identifier() : null;
var suffix = lookingAtIdentifierBody() ? identifierBody() : null;
return new ParentSelector(suffix: suffix);
}