summaryrefslogtreecommitdiffstats
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
parent38f206cb7288d8ef3f05e74e8201e9e662a0859a (diff)
downloadUXP-222d316c835019ce64603180e4a73b231b788d76.tar
UXP-222d316c835019ce64603180e4a73b231b788d76.tar.gz
UXP-222d316c835019ce64603180e4a73b231b788d76.tar.lz
UXP-222d316c835019ce64603180e4a73b231b788d76.tar.xz
UXP-222d316c835019ce64603180e4a73b231b788d76.zip
Bug 1425685 - Implement HTMLSlotElement.assignedElements();
Tag #1375
-rw-r--r--dom/html/HTMLSlotElement.cpp11
-rw-r--r--dom/html/HTMLSlotElement.h3
-rw-r--r--dom/webidl/HTMLSlotElement.webidl1
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 {