From 3e45f05d97b4528648b33512cc70019ba7c1e157 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Sun, 26 Jan 2020 11:17:48 -0500 Subject: [PATCH] Handle whitespace with interpolated super selector --- src/selector.rs | 5 +++-- tests/main.rs | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/selector.rs b/src/selector.rs index 11e2c19..8993b34 100644 --- a/src/selector.rs +++ b/src/selector.rs @@ -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::() ), - SelectorKind::InterpolatedSuper => write!(f, " "), - SelectorKind::Super | SelectorKind::None => { + SelectorKind::Super | SelectorKind::None | SelectorKind::InterpolatedSuper => { write!(f, "") } } diff --git a/tests/main.rs b/tests/main.rs index 8af5a56..066a8f2 100644 --- a/tests/main.rs +++ b/tests/main.rs @@ -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 }",