Implement `EventTarget` and `Event` builtin
This patch sets the stage for incoming AbortController and AbortSignal:
- implements
Eventinterface: https://dom.spec.whatwg.org/#interface-event, - implements
CustomEventinterface: https://dom.spec.whatwg.org/#interface-customevent, - implement
EventTargetinterface: https://dom.spec.whatwg.org/#interface-eventtarget, - adds a global
EventTargetinstance, - makes
FetchEventa subclass ofEventand uses globalEventTarget.
Closes: https://github.com/bytecodealliance/StarlingMonkey/issues/156
Great to see this. Strictly speaking FetchEvent is supposed to be a subclass of this Event. Not sure how practical that will be though, but I think that's the WinterTC expectation.
Great to see this. Strictly speaking
FetchEventis supposed to be a subclass of thisEvent. Not sure how practical that will be though, but I think that's the WinterTC expectation.
Yeah, I think it should be doable similar to how we made File extending Blob. I will look into this when I have a moment. I think the other nice to have event would be CustomEvent.
Strictly speaking FetchEvent is supposed to be a subclass of this Event.
So this is now working as expected, for instance this code shows FetchEvent using Event interface (event.type).
async function handler(event) {
console.log(event.type);
}
addEventListener("fetch", (event) =>
event.respondWith(
(async () => {
await handler(event);
return new Response(`Success`);
})(),
),
);
Looks great! Feel free to merge whenever