Handle whitespace with interpolated super selector

This commit is contained in:
ConnorSkees 2020-01-26 11:17:48 -05:00
parent 4e6ae91825
commit 3e45f05d97
2 changed files with 9 additions and 3 deletions

View File

@ -22,6 +22,7 @@ impl Display for Selector {
| SelectorKind::Class | SelectorKind::Class
| SelectorKind::Id | SelectorKind::Id
| SelectorKind::Universal | SelectorKind::Universal
| SelectorKind::InterpolatedSuper
| SelectorKind::Element(_) => { | SelectorKind::Element(_) => {
write!(f, "{}", s)?; write!(f, "{}", s)?;
if devour_whitespace(&mut iter) { if devour_whitespace(&mut iter) {
@ -32,6 +33,7 @@ impl Display for Selector {
| Some(SelectorKind::Class) | Some(SelectorKind::Class)
| Some(SelectorKind::Id) | Some(SelectorKind::Id)
| Some(SelectorKind::Universal) | Some(SelectorKind::Universal)
| Some(SelectorKind::InterpolatedSuper)
| Some(SelectorKind::Element(_)) => { | Some(SelectorKind::Element(_)) => {
write!(f, " ")?; write!(f, " ")?;
} }
@ -111,8 +113,7 @@ impl Display for SelectorKind {
s, s,
toks.iter().map(ToString::to_string).collect::<String>() toks.iter().map(ToString::to_string).collect::<String>()
), ),
SelectorKind::InterpolatedSuper => write!(f, " "), SelectorKind::Super | SelectorKind::None | SelectorKind::InterpolatedSuper => {
SelectorKind::Super | SelectorKind::None => {
write!(f, "") write!(f, "")
} }
} }

View File

@ -260,10 +260,15 @@ mod test_selectors {
"a b a {\n color: red;\n}\n" "a b a {\n color: red;\n}\n"
); );
test!( test!(
selector_interpolation_super_selector_root, selector_interpolation_super_selector_root_postfix,
"a#{&} {\nb { color: red; }}", "a#{&} {\nb { color: red; }}",
"a b {\n color: red;\n}\n" "a b {\n color: red;\n}\n"
); );
test!(
selector_interpolation_super_selector_root_prefix,
"#{&}a {\nb { color: red; }}",
"a b {\n color: red;\n}\n"
);
test!( test!(
selector_whitespace, selector_whitespace,
" a > b , c ~ d e .f #g :h i.j [ k ] { color: red }", " a > b , c ~ d e .f #g :h i.j [ k ] { color: red }",