Issue #2250 - Part 1: Return early if the element being tested for is likely an ancestor and does not have an assigned slot

This commit is contained in:
FranklinDM 2023-05-21 15:17:29 +08:00 committed by roytam1
commit 1c2dd6aee0

View file

@ -1732,7 +1732,13 @@ static bool SelectorMatches(Element* aElement,
Element* targetElement = aElement;
if (aTreeMatchContext.mForAssignedSlot) {
targetElement = aElement->GetAssignedSlot()->AsElement();
HTMLSlotElement* slot = aElement->GetAssignedSlot();
// We're likely testing the slottable's ancestors and it might
// not have an assigned slot, so return early.
if (!slot) {
return false;
}
targetElement = slot->AsElement();
}
// namespace/tag match