From 8846a09d1cc2305f35fbc98ee34c5fb7bd23c29f Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Mon, 1 Jun 2020 21:44:07 -0400 Subject: [PATCH] @ else is case sensitive --- src/atrule/if_rule.rs | 20 +++++++++----------- tests/if.rs | 7 ++++++- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/atrule/if_rule.rs b/src/atrule/if_rule.rs index 443d406..a41c75f 100644 --- a/src/atrule/if_rule.rs +++ b/src/atrule/if_rule.rs @@ -64,18 +64,16 @@ impl If { let mut else_ = Vec::new(); loop { - match toks.peek().cloned() { - Some(Token { kind: '@', pos }) => { - toks.peek_forward(1); - let mut ident = peek_ident_no_interpolation(toks, false, pos)?; - ident.node.make_ascii_lowercase(); - if ident.as_str() != "else" { - toks.reset_view(); - break; - } - toks.take(4).for_each(drop); + if let Some(Token { kind: '@', pos }) = toks.peek().cloned() { + toks.peek_forward(1); + let ident = peek_ident_no_interpolation(toks, false, pos)?; + if ident.as_str() != "else" { + toks.reset_view(); + break; } - Some(..) | None => break, + toks.take(4).for_each(drop); + } else { + break; } devour_whitespace(toks); if let Some(tok) = toks.next() { diff --git a/tests/if.rs b/tests/if.rs index ab17cf8..7102fad 100644 --- a/tests/if.rs +++ b/tests/if.rs @@ -106,7 +106,12 @@ test!( test!( uppercase_escaped_else, "@if false {}\n\n@\\45lse {\n a {\n color: red;\n }\n}\n", - "a {\n color: red;\n}\n" + "@Else {\n a {\n color: red;\n }\n}\n" +); +test!( + uppercase_else, + "@if false {}\n\n@Else {\n a {\n color: red;\n }\n}\n", + "@Else {\n a {\n color: red;\n }\n}\n" ); test!(uppercase_if, "@If true {\n a {\n color: red;\n }\n}\n"); error!(nothing_after_if, "@if", "Error: Expected expression.");