From eea8bdbc2587aa2cab28bddf95d1a12c321f5b53 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Sat, 16 May 2020 16:15:11 -0400 Subject: [PATCH] allow escapes at the start of selectors --- src/stylesheet.rs | 2 +- tests/selectors.rs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/stylesheet.rs b/src/stylesheet.rs index 906d311..d25a291 100644 --- a/src/stylesheet.rs +++ b/src/stylesheet.rs @@ -157,7 +157,7 @@ impl<'a> StyleSheetParser<'a> { while let Some(Token { kind, .. }) = self.lexer.peek() { match kind { 'a'..='z' | 'A'..='Z' | '_' | '-' | '0'..='9' - | '[' | '#' | ':' | '*' | '%' | '.' | '>' => rules + | '[' | '#' | ':' | '*' | '%' | '.' | '>' | '\\' => rules .extend(self.eat_rules(&Selector::new(), &mut Scope::new())?), &'\t' | &'\n' | ' ' => { self.lexer.next(); diff --git a/tests/selectors.rs b/tests/selectors.rs index c6cd536..8eacf9f 100644 --- a/tests/selectors.rs +++ b/tests/selectors.rs @@ -507,3 +507,8 @@ test!( "a, %b {\n color: nth(&, 2);\n}\n", "a {\n color: %b;\n}\n" ); +test!( + escape_at_start_of_selector, + "\\61 {\n color: red;\n}\n", + "a {\n color: red;\n}\n" +);