Skip to content

Commit

Permalink
Fix event.stopImmediatePropagation()
Browse files Browse the repository at this point in the history
It previously only stopped propagation, not immediate propagation.
  • Loading branch information
Sebmaster authored and domenic committed Mar 12, 2017
1 parent 5069d64 commit 8838684
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/jsdom/living/events/Event-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class EventImpl {

stopImmediatePropagation() {
this._stopPropagationFlag = true;
this._stopImmediatePropagation = true;
this._stopImmediatePropagationFlag = true;
}

preventDefault() {
Expand Down
1 change: 1 addition & 0 deletions test/web-platform-tests/to-upstream.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe("Local tests in Web Platform Test format (to-upstream)", () => {
"dom/attributes-are-not-nodes.html",
"dom/collections/HTMLCollection-iterator.html",
"dom/events/AddEventListenerOptions-once.html",
"dom/events/Event-stopImmediatePropagation.html",
"dom/events/EventTarget-add-remove-listener.html",
"dom/events/EventTarget-prototype-constructor.html",
"dom/events/EventTarget-this-of-listener.html",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Event's stopImmediatePropagation</title>
<link rel="help" href="https://dom.spec.whatwg.org/#dom-event-stopimmediatepropagation">
<link rel="author" href="mailto:[email protected]" title="Domenic Denicola">

<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<div id="target"></div>

<script>
"use strict";

const target = document.querySelector("#target");

let timesCalled = 0;
target.addEventListener("test", e => {
++timesCalled;
e.stopImmediatePropagation();
assert_equals(e.cancelBubble, true, "The stop propagation flag must have been set");
});
target.addEventListener("test", () => {
++timesCalled;
});

const e = new Event("test");
target.dispatchEvent(e);
assert_equals(timesCalled, 1, "The second listener must not have been called");

done();
</script>

0 comments on commit 8838684

Please sign in to comment.