no longer strip whitespace at the end of selectors

the whitespace can sometimes be part of an escape, e.g. `\ `
This commit is contained in:
Connor Skees 2020-06-30 06:43:26 -04:00
parent 8622efc7be
commit f476f4af25
3 changed files with 9 additions and 12 deletions

View File

@ -333,14 +333,6 @@ impl<'a> Parser<'a> {
return Err(("expected \"{\".", span).into());
}
while let Some(c) = string.pop() {
if c == ' ' || c == ',' || c == '\t' {
continue;
}
string.push(c);
break;
}
let sel_toks: Vec<Token> = string.chars().map(|x| Token::new(span, x)).collect();
let mut iter = sel_toks.into_iter().peekmore();

View File

@ -587,10 +587,10 @@ fn unvendor(name: &str) -> &str {
/// with pseudo-class syntax (`:before`, `:after`, `:first-line`, or
/// `:first-letter`)
fn is_fake_pseudo_element(name: &str) -> bool {
match name.as_bytes()[0] {
b'a' | b'A' => name.to_ascii_lowercase() == "after",
b'b' | b'B' => name.to_ascii_lowercase() == "before",
b'f' | b'F' => match name.to_ascii_lowercase().as_str() {
match name.as_bytes().get(0) {
Some(b'a') | Some(b'A') => name.to_ascii_lowercase() == "after",
Some(b'b') | Some(b'B') => name.to_ascii_lowercase() == "before",
Some(b'f') | Some(b'F') => match name.to_ascii_lowercase().as_str() {
"first-line" | "first-letter" => true,
_ => false,
},

View File

@ -653,6 +653,11 @@ test!(
":nth-child(ODD) {\n color: &;\n}\n",
":nth-child(odd) {\n color: :nth-child(odd);\n}\n"
);
test!(
escaped_space_at_end_of_selector_immediately_after_pseudo_color,
"a color:\\ {\n color: &;\n}\n",
"a color:\\ {\n color: a color:\\ ;\n}\n"
);
test!(
super_selector_is_null_when_at_root,
"@mixin foo {\n #{if(&, 'true', 'false')} {\n color: red;\n }\n}\n\n@include foo;\n\na {\n @include foo;\n}\n",