Skip to content

Commit 1c70b18

Browse files
jasnellcodebytere
authored andcommitted
events: initial implementation of experimental EventTarget
See documentation changes for details Signed-off-by: James M Snell <[email protected]> PR-URL: #33556 Refs: #33527 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Bradley Farias <[email protected]>
1 parent 20d54f6 commit 1c70b18

File tree

8 files changed

+1316
-0
lines changed

8 files changed

+1316
-0
lines changed

benchmark/events/eventtarget.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict';
2+
const common = require('../common.js');
3+
4+
const bench = common.createBenchmark(main, {
5+
n: [2e7],
6+
listeners: [1, 5, 10]
7+
}, { flags: ['--expose-internals'] });
8+
9+
function main({ n, listeners }) {
10+
const { EventTarget, Event } = require('internal/event_target');
11+
const target = new EventTarget();
12+
13+
for (let n = 0; n < listeners; n++)
14+
target.addEventListener('foo', () => {});
15+
16+
const event = new Event('foo');
17+
18+
bench.start();
19+
for (let i = 0; i < n; i++) {
20+
target.dispatchEvent(event);
21+
}
22+
bench.end(n);
23+
24+
}

doc/api/errors.md

+5
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,11 @@ Encoding provided to `TextDecoder()` API was not one of the
903903

904904
`--print` cannot be used with ESM input.
905905

906+
<a id="ERR_EVENT_RECURSION"></a>
907+
### `ERR_EVENT_RECURSION`
908+
909+
Thrown when an attempt is made to recursively dispatch an event on `EventTarget`.
910+
906911
<a id="ERR_EXECUTION_ENVIRONMENT_NOT_AVAILABLE"></a>
907912
### `ERR_EXECUTION_ENVIRONMENT_NOT_AVAILABLE`
908913

0 commit comments

Comments
 (0)