Bug 1425685 - Implement HTMLSlotElement.assignedElements(); r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D15653

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Edgar Chen 2019-01-03 19:14:12 +00:00
Родитель 7a748ae68f
Коммит 1990d76d46
6 изменённых файлов: 15 добавлений и 29 удалений

Просмотреть файл

@ -141,6 +141,17 @@ void 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 {
return mAssignedNodes;
}

Просмотреть файл

@ -50,6 +50,9 @@ class HTMLSlotElement final : public nsGenericHTMLElement {
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);

Просмотреть файл

@ -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 {

Просмотреть файл

@ -631,15 +631,6 @@
[HTMLDialogElement interface: operation close(DOMString)]
expected: FAIL
[HTMLSlotElement interface: operation assignedElements(AssignedNodesOptions)]
expected: FAIL
[HTMLSlotElement interface: document.createElement("slot") must inherit property "assignedElements(AssignedNodesOptions)" with the proper type]
expected: FAIL
[HTMLSlotElement interface: calling assignedElements(AssignedNodesOptions) on document.createElement("slot") with too few arguments must throw TypeError]
expected: FAIL
[HTMLCanvasElement interface: operation transferControlToOffscreen()]
expected: FAIL

Просмотреть файл

@ -1,10 +0,0 @@
[slots-fallback.html]
[Slots fallback: Basic, elements only.]
expected: FAIL
[Slots fallback: Slots in Slots, elements only.]
expected: FAIL
[Slots fallback: Complex case, elements only.]
expected: FAIL

Просмотреть файл

@ -1,10 +0,0 @@
[slots.html]
[Slots: Basic, elements only.]
expected: FAIL
[Slots: Slots in closed, elements only.]
expected: FAIL
[Slots: Slots not in a shadow tree, elements only.]
expected: FAIL