Bug 1411878 - Support Element.shadowRoot and Element.assignedSlot / TextNode.assignedSlot on closed shadow root

Tag #1375
This commit is contained in:
Matt A. Tobin 2020-04-17 07:05:27 -04:00 • committed by Roy Tam
commit 31b26a24e3
8 changed files with 67 additions and 11 deletions

View file

@ -152,6 +152,36 @@ nsIContent::FindFirstNonChromeOnlyAccessContent() const
return nullptr;
}
// https://dom.spec.whatwg.org/#dom-slotable-assignedslot
HTMLSlotElement*
nsIContent::GetAssignedSlotByMode() const
{
/**
* Get slotable's assigned slot for the result of
* find a slot with open flag UNSET [1].
*
* [1] https://dom.spec.whatwg.org/#assign-a-slot
*/
HTMLSlotElement* slot = GetAssignedSlot();
if (!slot) {
return nullptr;
}
MOZ_ASSERT(GetParent());
MOZ_ASSERT(GetParent()->GetShadowRoot());
/**
* Additional check for open flag SET:
* If slotable’s parent’s shadow root's mode is not "open",
* then return null.
*/
if (GetParent()->GetShadowRoot()->IsClosed()) {
return nullptr;
}
return slot;
}
nsINode*
nsIContent::GetFlattenedTreeParentNodeInternal(FlattenedParentType aType) const
{