1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:27:46 +00:00

LibWeb: Implement the :where() selector

This is identical to :is() except for specificity, so we can use the
same code paths. :^)
This commit is contained in:
Sam Atkins 2022-03-17 16:13:13 +00:00 committed by Andreas Kling
parent 47eb4b2db7
commit 993653317c
5 changed files with 22 additions and 8 deletions

View file

@ -159,6 +159,7 @@ String Selector::SimpleSelector::serialize() const
case Selector::SimpleSelector::PseudoClass::Type::NthLastChild:
case Selector::SimpleSelector::PseudoClass::Type::Not:
case Selector::SimpleSelector::PseudoClass::Type::Is:
case Selector::SimpleSelector::PseudoClass::Type::Where:
// Otherwise, append ":" (U+003A), followed by the name of the pseudo-class, followed by "(" (U+0028),
// followed by the value of the pseudo-class argument(s) determined as per below, followed by ")" (U+0029), to s.
s.append(':');
@ -169,9 +170,10 @@ String Selector::SimpleSelector::serialize() const
// The result of serializing the value using the rules to serialize an <an+b> value.
s.append(pseudo_class.nth_child_pattern.serialize());
} else if (pseudo_class.type == Selector::SimpleSelector::PseudoClass::Type::Not
|| pseudo_class.type == Selector::SimpleSelector::PseudoClass::Type::Is) {
|| pseudo_class.type == Selector::SimpleSelector::PseudoClass::Type::Is
|| pseudo_class.type == Selector::SimpleSelector::PseudoClass::Type::Where) {
// The result of serializing the value using the rules for serializing a group of selectors.
// NOTE: `:is()` isn't in the spec for this yet, but it should be!
// NOTE: `:is()` and `:where()` aren't in the spec for this yet, but it should be!
s.append(serialize_a_group_of_selectors(pseudo_class.argument_selector_list));
}
s.append(')');