@@ -1069,9 +1069,15 @@ const ac = new AbortController();
10691069process .nextTick (() => ac .abort ());
10701070```
10711071
1072+ <a id =" event-target-and-event-api " ></a >
10721073## ` EventTarget ` and ` Event ` API
10731074<!-- YAML
10741075added: v14.5.0
1076+ changes:
1077+ - version: REPLACEME
1078+ pr-url: https://github.com/nodejs/node/pull/35496
1079+ description:
1080+ The `EventTarget` and `Event` classes are now available as globals.
10751081-->
10761082
10771083> Stability: 1 - Experimental
@@ -1082,7 +1088,7 @@ Neither the `EventTarget` nor `Event` classes are available for end
10821088user code to create.
10831089
10841090``` js
1085- const target = getEventTargetSomehow ();
1091+ const target = new EventTarget ();
10861092
10871093target .addEventListener (' foo' , (event ) => {
10881094 console .log (' foo event happened!' );
@@ -1168,7 +1174,7 @@ const handler4 = {
11681174 }
11691175};
11701176
1171- const target = getEventTargetSomehow ();
1177+ const target = new EventTarget ();
11721178
11731179target .addEventListener (' foo' , handler1);
11741180target .addEventListener (' foo' , handler2);
@@ -1189,6 +1195,10 @@ The `EventTarget` does not implement any special default handling for
11891195### Class: ` Event `
11901196<!-- YAML
11911197added: v14.5.0
1198+ changes:
1199+ - version: REPLACEME
1200+ pr-url: https://github.com/nodejs/node/pull/35496
1201+ description: The `Event` class is now available through the global object.
11921202-->
11931203
11941204The ` Event ` object is an adaptation of the [ ` Event ` Web API] [ ] . Instances
@@ -1341,6 +1351,11 @@ The event type identifier.
13411351### Class: ` EventTarget `
13421352<!-- YAML
13431353added: v14.5.0
1354+ changes:
1355+ - version: REPLACEME
1356+ pr-url: https://github.com/nodejs/node/pull/35496
1357+ description:
1358+ The `EventTarget` class is now available through the global object.
13441359-->
13451360
13461361#### ` eventTarget.addEventListener(type, listener[, options]) `
@@ -1374,7 +1389,7 @@ a `listener`. Any individual `listener` may be added once with
13741389``` js
13751390function handler (event ) {}
13761391
1377- const target = getEventTargetSomehow ();
1392+ const target = new EventTarget ();
13781393target .addEventListener (' foo' , handler, { capture: true }); // first
13791394target .addEventListener (' foo' , handler, { capture: false }); // second
13801395
0 commit comments