Support reference combinators.

This commit is contained in:
Natalie Weizenbaum 2016-10-21 21:21:30 -07:00
parent 20eb3584bc
commit a3142d526e
3 changed files with 19 additions and 1 deletions

View File

@ -123,3 +123,15 @@ class Combinator implements ComplexSelectorComponent {
String toString() => _text;
}
/// A reference combinator, like `/for/`.
class ReferenceCombinator implements Combinator {
/// The name of the attribute being selected for.
final String name;
String get _text => "/$name/";
ReferenceCombinator(this.name);
String toString() => _text;
}

View File

@ -95,6 +95,12 @@ class SelectorParser extends Parser {
component = Combinator.followingSibling;
break;
case $slash:
scanner.readChar();
component = new ReferenceCombinator(identifier());
scanner.expectChar($slash);
break;
case $lbracket:
case $dot:
case $hash:

View File

@ -1814,7 +1814,7 @@ abstract class StylesheetParser extends Parser {
if (scanComment()) {
buffer.write(scanner.substring(commentStart));
} else {
buffer.write(scanner.readChar());
buffer.writeCharCode(scanner.readChar());
}
break;