summaryrefslogtreecommitdiff
path: root/dom/html
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-04-17 12:27:45 -0400
committerMatt A. Tobin <email@mattatobin.com>2020-04-17 12:27:45 -0400
commit222d316c835019ce64603180e4a73b231b788d76 (patch)
tree6c397c7ea7ad627317bddaa157b30405f12314b5 /dom/html
parent38f206cb7288d8ef3f05e74e8201e9e662a0859a (diff)
downloaduxp-222d316c835019ce64603180e4a73b231b788d76.tar.gz
Bug 1425685 - Implement HTMLSlotElement.assignedElements();
Tag #1375
Diffstat (limited to 'dom/html')
-rw-r--r--dom/html/HTMLSlotElement.cpp11
-rw-r--r--dom/html/HTMLSlotElement.h3
2 files changed, 14 insertions, 0 deletions
diff --git a/dom/html/HTMLSlotElement.cpp b/dom/html/HTMLSlotElement.cpp
index 18b8ef87bf..1c17037af8 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 0494a654e6..51affc2af2 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);