lib: expose global ErrorEvent

PR-URL: https://github.com/nodejs/node/pull/58920
Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com>
Reviewed-By: Matthew Aitken <maitken033380023@gmail.com>
Reviewed-By: Jason Zhang <xzha4350@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
This commit is contained in:
Richie Bendall 2025-08-18 20:14:54 +12:00 committed by GitHub
parent f5e6ba3d7c
commit 663554abdf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 16 additions and 1 deletions

View File

@ -454,6 +454,14 @@ changes:
A browser-compatible implementation of [`DecompressionStream`][].
## `ErrorEvent`
<!-- YAML
added: REPLACEME
-->
A browser-compatible implementation of {ErrorEvent}.
## Class: `Event`
<!-- YAML

View File

@ -108,6 +108,10 @@ export default [
name: 'DOMException',
message: "Use lazy function `const { lazyDOMExceptionClass } = require('internal/util');` instead of the global.",
},
{
name: 'ErrorEvent',
message: "Use `const { ErrorEvent } = require('internal/deps/undici/undici');` instead of the global.",
},
{
name: 'Event',
message: "Use `const { Event } = require('internal/event_target');` instead of the global.",

View File

@ -89,7 +89,7 @@ ObjectDefineProperty(globalThis, 'fetch', {
// https://fetch.spec.whatwg.org/#request-class
// https://fetch.spec.whatwg.org/#response-class
exposeLazyInterfaces(globalThis, 'internal/deps/undici/undici', [
'FormData', 'Headers', 'Request', 'Response', 'MessageEvent', 'CloseEvent',
'FormData', 'Headers', 'Request', 'Response', 'MessageEvent', 'CloseEvent', 'ErrorEvent',
]);
// https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events.org/

View File

@ -132,6 +132,7 @@ const webIdlExposedWindow = new Set([
'WebSocket',
'EventSource',
'CloseEvent',
'ErrorEvent',
]);
const nodeGlobals = new Set([

View File

@ -12,6 +12,7 @@ export default [
globals: {
...globals.node,
CloseEvent: true,
ErrorEvent: true,
},
},
rules: {

View File

@ -140,6 +140,7 @@ const customTypesMap = {
'EventListener': 'events.html#event-listener',
'CloseEvent': `${mdnPrefix}/API/CloseEvent`,
'ErrorEvent': `${mdnPrefix}/API/ErrorEvent`,
'EventSource': `${mdnPrefix}/API/EventSource`,
'MessageEvent': `${mdnPrefix}/API/MessageEvent`,