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

View File

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