diff options
-rw-r--r-- | dom/html/HTMLSlotElement.cpp | 11 | ||||
-rw-r--r-- | dom/html/HTMLSlotElement.h | 3 | ||||
-rw-r--r-- | dom/webidl/HTMLSlotElement.webidl | 1 |
3 files changed, 15 insertions, 0 deletions
diff --git a/dom/html/HTMLSlotElement.cpp b/dom/html/HTMLSlotElement.cpp index 18b8ef87b..1c17037af 100644 --- a/dom/html/HTMLSlotElement.cpp +++ b/dom/html/HTMLSlotElement.cpp @@ -168,6 +168,17 @@ HTMLSlotElement::AssignedNodes(const AssignedNodesOptions& aOptions, aNodes = mAssignedNodes; } +void HTMLSlotElement::AssignedElements(const AssignedNodesOptions& aOptions, + nsTArray<RefPtr<Element>>& aElements) { + AutoTArray<RefPtr<nsINode>, 128> assignedNodes; + AssignedNodes(aOptions, assignedNodes); + for (const RefPtr<nsINode>& assignedNode : assignedNodes) { + if (assignedNode->IsElement()) { + aElements.AppendElement(assignedNode->AsElement()); + } + } +} + const nsTArray<RefPtr<nsINode>>& HTMLSlotElement::AssignedNodes() const { diff --git a/dom/html/HTMLSlotElement.h b/dom/html/HTMLSlotElement.h index 0494a654e..51affc2af 100644 --- a/dom/html/HTMLSlotElement.h +++ b/dom/html/HTMLSlotElement.h @@ -55,6 +55,9 @@ public: void AssignedNodes(const AssignedNodesOptions& aOptions, nsTArray<RefPtr<nsINode>>& aNodes); + void AssignedElements(const AssignedNodesOptions& aOptions, + nsTArray<RefPtr<Element>>& aNodes); + // Helper methods const nsTArray<RefPtr<nsINode>>& AssignedNodes() const; void InsertAssignedNode(uint32_t aIndex, nsINode* aNode); diff --git a/dom/webidl/HTMLSlotElement.webidl b/dom/webidl/HTMLSlotElement.webidl index 24dfcf350..9fd2da628 100644 --- a/dom/webidl/HTMLSlotElement.webidl +++ b/dom/webidl/HTMLSlotElement.webidl @@ -15,6 +15,7 @@ interface HTMLSlotElement : HTMLElement { [CEReactions, SetterThrows] attribute DOMString name; sequence<Node> assignedNodes(optional AssignedNodesOptions options); + sequence<Element> assignedElements(optional AssignedNodesOptions options); }; dictionary AssignedNodesOptions { |