From 25862a5af8ffb32299d863841c3c303aabbe911e Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Tue, 7 Jul 2020 11:37:20 -0400 Subject: [PATCH] do not strip whitespace before comma in psuedo selector --- src/parse/mod.rs | 11 +---------- tests/selectors.rs | 5 +++++ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/parse/mod.rs b/src/parse/mod.rs index 0e3bd87..35ad39e 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -319,6 +319,7 @@ impl<'a> Parser<'a> { let mut found_curly = false; + // we resolve interpolation and strip comments while let Some(tok) = self.toks.next() { span = span.merge(tok.pos()); match tok.kind { @@ -330,16 +331,6 @@ impl<'a> Parser<'a> { string.push('#'); } } - ',' => { - while let Some(c) = string.pop() { - if c == ' ' || c == ',' { - continue; - } - string.push(c); - string.push(','); - break; - } - } '/' => { if self.toks.peek().is_none() { return Err(("Expected selector.", tok.pos()).into()); diff --git a/tests/selectors.rs b/tests/selectors.rs index 74fc127..7b415fd 100644 --- a/tests/selectors.rs +++ b/tests/selectors.rs @@ -668,6 +668,11 @@ test!( "a, // 1\nb,\nc {\n color: red;\n}\n", "a,\nb,\nc {\n color: red;\n}\n" ); +test!( + spaces_are_preserved_before_comma_in_pseudo_arg, + ":a(a , b) {\n color: &;\n}\n", + ":a(a , b) {\n color: :a(a , b);\n}\n" +); error!( a_n_plus_b_n_invalid_odd, ":nth-child(ofdd) {\n color: &;\n}\n", "Error: Expected \"odd\"."