Issue #1592 - Part 2: Parse ::slotted() pseudo-element as if it were a pseudo-class

- Block slot elements from being matched by ::slotted
- Ensure ::slotted() is serialized as a pseudo-element
- Add pref to control whether the pseudo-class is enabled
This commit is contained in:
FranklinDM 2023-03-18 09:36:25 +08:00 committed by roytam1
commit 77ad970db6
8 changed files with 81 additions and 3 deletions

View file

@ -1963,6 +1963,29 @@ static bool SelectorMatches(Element* aElement,
}
break;
case CSSPseudoClassType::slotted:
{
// Slot elements cannot be matched.
if (aElement->IsHTMLElement(nsGkAtoms::slot)) {
return false;
}
// The current element must have an assigned slot.
if (!aElement->GetAssignedSlot()) {
return false;
}
NodeMatchContext nodeContext(EventStates(),
aNodeMatchContext.mIsRelevantLink);
if (!SelectorListMatches(aElement,
pseudoClass,
nodeContext,
aTreeMatchContext)) {
return false;
}
}
break;
case CSSPseudoClassType::host:
{
ShadowRoot* shadow = aElement->GetShadowRoot();