From 4ca6e304a5603fe4c81d0b4018451f3dc0fb5520 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Mon, 20 Apr 2020 10:57:35 -0400 Subject: [PATCH] allow at-rules other than else to follow @ if --- src/atrule/if_rule.rs | 5 +++++ tests/if.rs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/atrule/if_rule.rs b/src/atrule/if_rule.rs index 4bf4be7..555e8bf 100644 --- a/src/atrule/if_rule.rs +++ b/src/atrule/if_rule.rs @@ -50,6 +50,11 @@ impl If { loop { if toks.peek().is_some() { if toks.peek().unwrap().kind == '@' { + let first_char = toks.peek_forward(1).unwrap().kind; + toks.peek_backward(1).unwrap(); + if first_char != 'e' && first_char != 'E' { + break; + } toks.next(); } else { break; diff --git a/tests/if.rs b/tests/if.rs index dc762c4..f7d3e18 100644 --- a/tests/if.rs +++ b/tests/if.rs @@ -67,3 +67,8 @@ test!( "a {\n @if true {\n color: red\n }\n}\n", "a {\n color: red;\n}\n" ); +test!( + atrule_other_than_else_immediately_following, + "a {\n @if true {\n b {\n background: gray;\n }\n }\n\n @if true {\n b {\n background: gray;\n }\n }\n}\n", + "a b {\n background: gray;\n}\na b {\n background: gray;\n}\n" +);