LibWeb: Fix CSS selector combinator serialization

Two bugs here:
- We were looking at the wrong CompoundSelector's combinator.
- We weren't adding a space after the combinator.
This commit is contained in:
Sam Atkins 2021-10-15 11:51:54 +01:00 committed by Linus Groh
commit 3deb58e4bc
Notes: sideshowbarker 2024-07-18 02:18:20 +09:00

View file

@ -195,18 +195,20 @@ String Selector::serialize() const
// single SPACE (U+0020) if the combinator was not whitespace, to s.
if (i != compound_selectors().size() - 1) {
s.append(' ');
switch (compound_selector.combinator) {
// Note: The combinator that appears between parts `i` and `i+1` appears with the `i+1` selector,
// so we have to check that one.
switch (compound_selectors()[i + 1].combinator) {
case Selector::Combinator::ImmediateChild:
s.append('>');
s.append("> ");
break;
case Selector::Combinator::NextSibling:
s.append('+');
s.append("+ ");
break;
case Selector::Combinator::SubsequentSibling:
s.append('~');
s.append("~ ");
break;
case Selector::Combinator::Column:
s.append("||");
s.append("|| ");
break;
default:
break;