Parse (but do not remove) placeholder selectors

This commit is contained in:
ConnorSkees 2020-01-29 20:02:02 -05:00
parent c43aa18e06
commit 849cddeea4
3 changed files with 6 additions and 1 deletions

View File

@ -320,6 +320,7 @@ impl<'a> StyleSheetParser<'a> {
| TokenKind::Symbol(Symbol::Hash)
| TokenKind::Symbol(Symbol::Colon)
| TokenKind::Symbol(Symbol::Mul)
| TokenKind::Symbol(Symbol::Percent)
| TokenKind::Symbol(Symbol::Period) => rules
.extend(self.eat_rules(&Selector(Vec::new()), &mut self.global_scope.clone())),
TokenKind::Whitespace(_) => {

View File

@ -89,6 +89,8 @@ pub(crate) enum SelectorKind {
Super,
/// Super selector in an interpolated context: `a #{&}`
InterpolatedSuper,
/// Placeholder selector: `%alert`
Placeholder,
/// Used to signify no selector (when there is no super_selector of a rule)
None,
Whitespace,
@ -129,6 +131,7 @@ impl Display for SelectorKind {
SelectorKind::Super | SelectorKind::None | SelectorKind::InterpolatedSuper => {
write!(f, "")
}
SelectorKind::Placeholder => write!(f, "%"),
}
}
}
@ -269,6 +272,7 @@ impl<'a> SelectorParser<'a> {
TokenKind::Symbol(Symbol::Plus) => self.selectors.push(SelectorKind::Following),
TokenKind::Symbol(Symbol::Tilde) => self.selectors.push(SelectorKind::Preceding),
TokenKind::Symbol(Symbol::Mul) => self.selectors.push(SelectorKind::Universal),
TokenKind::Symbol(Symbol::Percent) => self.selectors.push(SelectorKind::Placeholder),
TokenKind::Symbol(Symbol::BitAnd) => self.selectors.push(if self.is_interpolated {
SelectorKind::InterpolatedSuper
} else {

View File

@ -304,7 +304,7 @@ impl Value {
}
Some(Value::Ident(s, QuoteKind::Single))
}
TokenKind::Variable(ref v) => Some(scope.vars.get(v).unwrap().clone()),
TokenKind::Variable(ref v) => Some(scope.vars.get(v).expect("expected variable").clone()),
TokenKind::Interpolation => {
let mut s = eat_interpolation(toks, scope)
.iter()