diff --git a/src/lib.rs b/src/lib.rs index 9cdead1..1df6f4d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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(_) => { diff --git a/src/selector.rs b/src/selector.rs index 062de91..5187e6d 100644 --- a/src/selector.rs +++ b/src/selector.rs @@ -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 { diff --git a/src/value.rs b/src/value.rs index 1b473cd..2072b21 100644 --- a/src/value.rs +++ b/src/value.rs @@ -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()