diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2021-10-15 11:53:23 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-10-16 15:16:27 +0100 |
commit | e5d3a9d10b313b53d2c17c14ba380cf81b38452e (patch) | |
tree | d78c3f549f7c9b81d8373a7ad33def9d8193f4f2 /Userland | |
parent | 3deb58e4bc9c9a81c7f20c20593f44870e396098 (diff) | |
download | serenity-e5d3a9d10b313b53d2c17c14ba380cf81b38452e.zip |
LibWeb: Fix pseudo-element selector serialization
We want to check the last SimpleSelector, not the first one. We don't
have to check that a SimpleSelector exists since a CompoundSelector
without one is invalid.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Selector.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Selector.cpp b/Userland/Libraries/LibWeb/CSS/Selector.cpp index 208fbccceb..425a7f9cac 100644 --- a/Userland/Libraries/LibWeb/CSS/Selector.cpp +++ b/Userland/Libraries/LibWeb/CSS/Selector.cpp @@ -214,12 +214,11 @@ String Selector::serialize() const break; } } else { - // 4. If this is the last part of the chain of the selector and there is a pseudo-element, append "::" followed by the name of the pseudo-element, to s. - // FIXME: This doesn't feel entirely correct. Our model of pseudo-elements seems off. - if (!compound_selector.simple_selectors.is_empty() - && compound_selector.simple_selectors.first().type == Selector::SimpleSelector::Type::PseudoElement) { + // 4. If this is the last part of the chain of the selector and there is a pseudo-element, + // append "::" followed by the name of the pseudo-element, to s. + if (compound_selector.simple_selectors.last().type == Selector::SimpleSelector::Type::PseudoElement) { s.append("::"); - s.append(pseudo_element_name(compound_selector.simple_selectors.first().pseudo_element)); + s.append(pseudo_element_name(compound_selector.simple_selectors.last().pseudo_element)); } } } |