mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:27:35 +00:00
LibWeb: Support the :last-of-type CSS selector :^)
This commit is contained in:
parent
0eb9a9dd13
commit
1d065aa51b
6 changed files with 25 additions and 0 deletions
|
@ -556,6 +556,8 @@ public:
|
|||
simple_selector.pseudo_class = CSS::Selector::SimpleSelector::PseudoClass::Root;
|
||||
} else if (pseudo_name.equals_ignoring_case("first-of-type")) {
|
||||
simple_selector.pseudo_class = CSS::Selector::SimpleSelector::PseudoClass::FirstOfType;
|
||||
} else if (pseudo_name.equals_ignoring_case("last-of-type")) {
|
||||
simple_selector.pseudo_class = CSS::Selector::SimpleSelector::PseudoClass::LastOfType;
|
||||
} else if (pseudo_name.equals_ignoring_case("before")) {
|
||||
simple_selector.pseudo_element = CSS::Selector::SimpleSelector::PseudoElement::Before;
|
||||
} else if (pseudo_name.equals_ignoring_case("after")) {
|
||||
|
|
|
@ -55,6 +55,7 @@ public:
|
|||
Empty,
|
||||
Root,
|
||||
FirstOfType,
|
||||
LastOfType,
|
||||
};
|
||||
PseudoClass pseudo_class { PseudoClass::None };
|
||||
|
||||
|
|
|
@ -96,6 +96,12 @@ static bool matches(const CSS::Selector::SimpleSelector& component, const DOM::E
|
|||
return false;
|
||||
}
|
||||
break;
|
||||
case CSS::Selector::SimpleSelector::PseudoClass::LastOfType:
|
||||
for (auto* sibling = element.next_element_sibling(); sibling; sibling = sibling->next_element_sibling()) {
|
||||
if (sibling->tag_name() == element.tag_name())
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
switch (component.attribute_match_type) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue