Skip to content

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), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Merge request reports

Loading