Parse (but do not remove) placeholder selectors
This commit is contained in:
parent
c43aa18e06
commit
849cddeea4
@ -320,6 +320,7 @@ impl<'a> StyleSheetParser<'a> {
|
|||||||
| TokenKind::Symbol(Symbol::Hash)
|
| TokenKind::Symbol(Symbol::Hash)
|
||||||
| TokenKind::Symbol(Symbol::Colon)
|
| TokenKind::Symbol(Symbol::Colon)
|
||||||
| TokenKind::Symbol(Symbol::Mul)
|
| TokenKind::Symbol(Symbol::Mul)
|
||||||
|
| TokenKind::Symbol(Symbol::Percent)
|
||||||
| TokenKind::Symbol(Symbol::Period) => rules
|
| TokenKind::Symbol(Symbol::Period) => rules
|
||||||
.extend(self.eat_rules(&Selector(Vec::new()), &mut self.global_scope.clone())),
|
.extend(self.eat_rules(&Selector(Vec::new()), &mut self.global_scope.clone())),
|
||||||
TokenKind::Whitespace(_) => {
|
TokenKind::Whitespace(_) => {
|
||||||
|
@ -89,6 +89,8 @@ pub(crate) enum SelectorKind {
|
|||||||
Super,
|
Super,
|
||||||
/// Super selector in an interpolated context: `a #{&}`
|
/// Super selector in an interpolated context: `a #{&}`
|
||||||
InterpolatedSuper,
|
InterpolatedSuper,
|
||||||
|
/// Placeholder selector: `%alert`
|
||||||
|
Placeholder,
|
||||||
/// Used to signify no selector (when there is no super_selector of a rule)
|
/// Used to signify no selector (when there is no super_selector of a rule)
|
||||||
None,
|
None,
|
||||||
Whitespace,
|
Whitespace,
|
||||||
@ -129,6 +131,7 @@ impl Display for SelectorKind {
|
|||||||
SelectorKind::Super | SelectorKind::None | SelectorKind::InterpolatedSuper => {
|
SelectorKind::Super | SelectorKind::None | SelectorKind::InterpolatedSuper => {
|
||||||
write!(f, "")
|
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::Plus) => self.selectors.push(SelectorKind::Following),
|
||||||
TokenKind::Symbol(Symbol::Tilde) => self.selectors.push(SelectorKind::Preceding),
|
TokenKind::Symbol(Symbol::Tilde) => self.selectors.push(SelectorKind::Preceding),
|
||||||
TokenKind::Symbol(Symbol::Mul) => self.selectors.push(SelectorKind::Universal),
|
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 {
|
TokenKind::Symbol(Symbol::BitAnd) => self.selectors.push(if self.is_interpolated {
|
||||||
SelectorKind::InterpolatedSuper
|
SelectorKind::InterpolatedSuper
|
||||||
} else {
|
} else {
|
||||||
|
@ -304,7 +304,7 @@ impl Value {
|
|||||||
}
|
}
|
||||||
Some(Value::Ident(s, QuoteKind::Single))
|
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 => {
|
TokenKind::Interpolation => {
|
||||||
let mut s = eat_interpolation(toks, scope)
|
let mut s = eat_interpolation(toks, scope)
|
||||||
.iter()
|
.iter()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user