Skip to content

Commit

Permalink
lib: let abort_controller target be EventTarget
Browse files Browse the repository at this point in the history
The AbortController abort event should have EventTarget as a target
property of the argument event.

PR-URL: #35869
Refs: https://github.com/web-platform-tests/wpt/blob/master/dom/abort/event.any.js
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
  • Loading branch information
watilde authored and targos committed Nov 3, 2020
1 parent 1303a1f commit d2f574b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions lib/internal/abort_controller.js
Expand Up @@ -10,6 +10,7 @@ const {
} = primordials;

const {
defineEventHandler,
EventTarget,
Event,
kTrustEvent
Expand Down Expand Up @@ -53,9 +54,6 @@ function abortSignal(signal) {
const event = new Event('abort', {
[kTrustEvent]: true
});
if (typeof signal.onabort === 'function') {
signal.onabort(event);
}
signal.dispatchEvent(event);
}

Expand All @@ -67,6 +65,7 @@ class AbortController {
constructor() {
this[kSignal] = new AbortSignal();
emitExperimentalWarning('AbortController');
defineEventHandler(this[kSignal], 'abort');
}

get signal() { return this[kSignal]; }
Expand Down
5 changes: 2 additions & 3 deletions lib/internal/event_target.js
Expand Up @@ -334,14 +334,13 @@ class EventTarget {
}
return event;
};
if (event !== undefined)
event[kTarget] = this;

const root = this[kEvents].get(type);
if (root === undefined || root.next === undefined)
return true;

if (event !== undefined)
event[kTarget] = this;

let handler = root.next;
let next;

Expand Down

0 comments on commit d2f574b

Please sign in to comment.