LibWeb: Support the :first-of-type CSS selector :^)

This commit is contained in:
Andreas Kling 2021-04-06 12:23:32 +02:00
commit 0eb9a9dd13
Notes: sideshowbarker 2024-07-18 20:44:00 +09:00
6 changed files with 26 additions and 0 deletions

View file

@ -90,6 +90,12 @@ static bool matches(const CSS::Selector::SimpleSelector& component, const DOM::E
if (!is<HTML::HTMLElement>(element))
return false;
break;
case CSS::Selector::SimpleSelector::PseudoClass::FirstOfType:
for (auto* sibling = element.previous_element_sibling(); sibling; sibling = sibling->previous_element_sibling()) {
if (sibling->tag_name() == element.tag_name())
return false;
}
break;
}
switch (component.attribute_match_type) {