events: support dispatching event from event
Currently our events guard against dispatching an event from itself by type rather than by event instance. This makes a WPT test fail.
Here's some code to demonstrate the issue.
{
const target = new EventTarget();
const event = new Event('foo');
let callCount = 0;
target.addEventListener('foo', (() => {
callCount++;
if (callCount < 5) {
target.dispatchEvent(new Event('foo'));
}
}, 5));
console.log(callCount)
}
Dispatching an event while handling it is still not supported (as required).
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
documentation is changed or added -
commit message follows commit guidelines