1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:28:12 +00:00

LibWeb: Implement the :is() selector

This lets us finally get rid of a FIXME in the default style sheet. :^)
This commit is contained in:
Sam Atkins 2022-03-17 15:28:42 +00:00 committed by Andreas Kling
parent 88d218721b
commit c148ed50bb
6 changed files with 37 additions and 21 deletions

View file

@ -158,6 +158,7 @@ String Selector::SimpleSelector::serialize() const
case Selector::SimpleSelector::PseudoClass::Type::NthChild:
case Selector::SimpleSelector::PseudoClass::Type::NthLastChild:
case Selector::SimpleSelector::PseudoClass::Type::Not:
case Selector::SimpleSelector::PseudoClass::Type::Is:
// 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(':');
@ -167,9 +168,11 @@ String Selector::SimpleSelector::serialize() const
|| pseudo_class.type == Selector::SimpleSelector::PseudoClass::Type::NthLastChild) {
// 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) {
} else if (pseudo_class.type == Selector::SimpleSelector::PseudoClass::Type::Not
|| pseudo_class.type == Selector::SimpleSelector::PseudoClass::Type::Is) {
// The result of serializing the value using the rules for serializing a group of selectors.
s.append(serialize_a_group_of_selectors(pseudo_class.not_selector));
// NOTE: `:is()` isn'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(')');
break;