1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:38:11 +00:00

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
parent ec51b40a4f
commit 3deb58e4bc

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;