Skip to content

Commit

Permalink
Bug 1491855 [wpt PR 13031] - DOM: test listener invocation order, a=t…
Browse files Browse the repository at this point in the history
…estonly

Automatic update from web-platform-tests
DOM: test listener invocation order

For whatwg/dom#686.

--

wpt-commits: 103df1bf782674889deb7136cdf7b1318dadb86b
wpt-pr: 13031
  • Loading branch information
annevk authored and jgraham committed Apr 1, 2019
1 parent 4cb56e6 commit 1dde707
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
test(t => {
const hostParent = document.createElement("section"),
host = hostParent.appendChild(document.createElement("div")),
shadowRoot = host.attachShadow({ mode: "closed" }),
targetParent = shadowRoot.appendChild(document.createElement("p")),
target = targetParent.appendChild(document.createElement("span")),
path = [hostParent, host, shadowRoot, targetParent, target],
expected = [],
result = [];
path.forEach((node, index) => {
expected.splice(index, 0, "capturing " + node.nodeName);
expected.splice(index + 1, 0, "bubbling " + node.nodeName);
});
path.forEach(node => {
node.addEventListener("test", () => { result.push("bubbling " + node.nodeName) });
node.addEventListener("test", () => { result.push("capturing " + node.nodeName) }, true);
});
target.dispatchEvent(new CustomEvent('test', { detail: {}, bubbles: true, composed: true }));
assert_array_equals(result, expected);
});

0 comments on commit 1dde707

Please sign in to comment.