Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

events: setting event cancelBubble calls stopPropagation #50405

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/internal/event_target.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ class Event {
if (!isEvent(this))
throw new ERR_INVALID_THIS('Event');
if (value) {
this.stopPropagation();
this.#propagationStopped = true;
Copy link

@jeanbern jeanbern Nov 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is setting cancelBubble supposed to be one-way? The proposed change doesn't modify this.#propagationStopped when value is false

nvm: For anyone else wondering the same thing see here: whatwg/dom#211

}
}

Expand Down
7 changes: 7 additions & 0 deletions test/parallel/test-eventtarget.js
Original file line number Diff line number Diff line change
Expand Up @@ -738,3 +738,10 @@ let asyncTest = Promise.resolve();
controller.abort();
et.dispatchEvent(new Event('foo'));
}

{
const event = new Event('foo');
strictEqual(event.cancelBubble, false);
event.cancelBubble = true;
strictEqual(event.cancelBubble, true);
}