LibWeb: Don't emit a simple selector if nothing was consumed

This commit is contained in:
Andreas Kling 2020-05-05 13:18:10 +02:00
parent 493cbb7956
commit 6676f2c259
Notes: sideshowbarker 2024-07-19 06:57:12 +09:00

View file

@ -268,6 +268,8 @@ public:
Optional<Selector::SimpleSelector> parse_simple_selector()
{
auto index_at_start = index;
if (consume_whitespace_or_comments())
return {};
@ -397,6 +399,11 @@ public:
simple_selector.pseudo_class = Selector::SimpleSelector::PseudoClass::Empty;
}
if (index == index_at_start) {
// We consumed nothing.
return {};
}
return simple_selector;
}