Closed
Description
- 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