diff options
author | Matt A. Tobin <email@mattatobin.com> | 2020-04-17 07:05:27 -0400 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2020-04-17 07:05:27 -0400 |
commit | 3a74795a56e92313c1b33a54500917794ba09b72 (patch) | |
tree | 949f2d97d27713e6a8960b948e51644bcaf27c02 /dom/base/FragmentOrElement.cpp | |
parent | 873abc7bcb6adc5cbf98ba3e1bd9a3271afc9806 (diff) | |
download | UXP-3a74795a56e92313c1b33a54500917794ba09b72.tar UXP-3a74795a56e92313c1b33a54500917794ba09b72.tar.gz UXP-3a74795a56e92313c1b33a54500917794ba09b72.tar.lz UXP-3a74795a56e92313c1b33a54500917794ba09b72.tar.xz UXP-3a74795a56e92313c1b33a54500917794ba09b72.zip |
Bug 1411878 - Support Element.shadowRoot and Element.assignedSlot / TextNode.assignedSlot on closed shadow root
Tag #1375
Diffstat (limited to 'dom/base/FragmentOrElement.cpp')
-rw-r--r-- | dom/base/FragmentOrElement.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/dom/base/FragmentOrElement.cpp b/dom/base/FragmentOrElement.cpp index 486bbc88c..766e2b115 100644 --- a/dom/base/FragmentOrElement.cpp +++ b/dom/base/FragmentOrElement.cpp @@ -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 { |