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

'abort' event on AbortSignal should be isTrusted: true #35748

Open
Jamesernator opened this issue Oct 22, 2020 · 0 comments
Open

'abort' event on AbortSignal should be isTrusted: true #35748

Jamesernator opened this issue Oct 22, 2020 · 0 comments
Labels

Comments

@Jamesernator
Copy link

@Jamesernator Jamesernator commented Oct 22, 2020

  • Version: 15.0.0
  • Platform: linux
  • Subsystem: events

This is a fairly minor thing, but might be relied upon and that's the fact that when .abort() is called on AbortController the isTrusted flag should be set.

For example this should print true:

const controller = new AbortController();
controller.signal.addEventListener('abort', event => console.log(event.isTrusted));
controller.abort();

Possible implementation:

It may be sufficient to just provide a way for the EventTarget constructor to mark events as trusted for that EventTarget e.g.:

let markAsTrusted;
const myTarget = new EventTarget(_markAsTrusted => markAsTrusted = _markAsTrusted);
const trustedEvent = markAsTrusted(new Event("my-event"));
myTarget.addEventListener("my-event", event => console.log(event.isTrusted));

myTarget.dispatchEvent(trustedEvent); // prints true

const trustedEvent2 = markAsTrusted(new Event("my-event"));
const myTarget2 = new EventTarget();
myTarget.dispatchEvent(trustedEvent); // throws Error, as this event has not been marked as trusted by this EventTarget but rather a different EventTarget
@PoojaDurgad PoojaDurgad added the events label Oct 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.