From b82eceeec0ff7fb2d5bab9a107c27067ee88e851 Mon Sep 17 00:00:00 2001 From: dandalf Date: Sun, 11 Jan 2026 01:11:36 -0700 Subject: [PATCH 1/6] have a draft working --- baselines/dom.generated.d.ts | 9 ++++--- baselines/ts5.5/dom.generated.d.ts | 9 ++++--- baselines/ts5.6/dom.generated.d.ts | 9 ++++--- baselines/ts5.9/dom.generated.d.ts | 9 ++++--- inputfiles/overridingTypes.jsonc | 13 ++++++++++ inputfiles/patches/events.kdl | 3 +-- src/build/emitter.ts | 31 +++++++++++++++++++---- unittests/files/onerror.ts | 40 ++++++++++++++++++++++++++++++ 8 files changed, 100 insertions(+), 23 deletions(-) create mode 100644 unittests/files/onerror.ts diff --git a/baselines/dom.generated.d.ts b/baselines/dom.generated.d.ts index 4c6832a09..a7f25ebc4 100644 --- a/baselines/dom.generated.d.ts +++ b/baselines/dom.generated.d.ts @@ -15096,7 +15096,7 @@ interface GlobalEventHandlersEventMap { "durationchange": Event; "emptied": Event; "ended": Event; - "error": ErrorEvent; + "error": Event; "focus": FocusEvent; "focusin": FocusEvent; "focusout": FocusEvent; @@ -15237,7 +15237,7 @@ interface GlobalEventHandlers { /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/ended_event) */ onended: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/error_event) */ - onerror: OnErrorEventHandler; + onerror: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/focus_event) */ onfocus: ((this: GlobalEventHandlers, ev: FocusEvent) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLFormElement/formdata_event) */ @@ -39460,6 +39460,7 @@ interface WindowEventMap extends GlobalEventHandlersEventMap, WindowEventHandler "devicemotion": DeviceMotionEvent; "deviceorientation": DeviceOrientationEvent; "deviceorientationabsolute": DeviceOrientationEvent; + "error": ErrorEvent; "gamepadconnected": GamepadEvent; "gamepaddisconnected": GamepadEvent; "orientationchange": Event; @@ -39612,6 +39613,7 @@ interface Window extends EventTarget, AnimationFrameProvider, GlobalEventHandler * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/deviceorientationabsolute_event) */ ondeviceorientationabsolute: ((this: Window, ev: DeviceOrientationEvent) => any) | null; + onerror: OnErrorEventHandler; /** * @deprecated * @@ -41794,6 +41796,7 @@ declare var ondeviceorientation: ((this: Window, ev: DeviceOrientationEvent) => * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/deviceorientationabsolute_event) */ declare var ondeviceorientationabsolute: ((this: Window, ev: DeviceOrientationEvent) => any) | null; +declare var onerror: OnErrorEventHandler; /** * @deprecated * @@ -42174,8 +42177,6 @@ declare var ondurationchange: ((this: Window, ev: Event) => any) | null; declare var onemptied: ((this: Window, ev: Event) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/ended_event) */ declare var onended: ((this: Window, ev: Event) => any) | null; -/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/error_event) */ -declare var onerror: OnErrorEventHandler; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/focus_event) */ declare var onfocus: ((this: Window, ev: FocusEvent) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLFormElement/formdata_event) */ diff --git a/baselines/ts5.5/dom.generated.d.ts b/baselines/ts5.5/dom.generated.d.ts index c3864e232..732061c66 100644 --- a/baselines/ts5.5/dom.generated.d.ts +++ b/baselines/ts5.5/dom.generated.d.ts @@ -15082,7 +15082,7 @@ interface GlobalEventHandlersEventMap { "durationchange": Event; "emptied": Event; "ended": Event; - "error": ErrorEvent; + "error": Event; "focus": FocusEvent; "focusin": FocusEvent; "focusout": FocusEvent; @@ -15223,7 +15223,7 @@ interface GlobalEventHandlers { /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/ended_event) */ onended: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/error_event) */ - onerror: OnErrorEventHandler; + onerror: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/focus_event) */ onfocus: ((this: GlobalEventHandlers, ev: FocusEvent) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLFormElement/formdata_event) */ @@ -39434,6 +39434,7 @@ interface WindowEventMap extends GlobalEventHandlersEventMap, WindowEventHandler "devicemotion": DeviceMotionEvent; "deviceorientation": DeviceOrientationEvent; "deviceorientationabsolute": DeviceOrientationEvent; + "error": ErrorEvent; "gamepadconnected": GamepadEvent; "gamepaddisconnected": GamepadEvent; "orientationchange": Event; @@ -39586,6 +39587,7 @@ interface Window extends EventTarget, AnimationFrameProvider, GlobalEventHandler * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/deviceorientationabsolute_event) */ ondeviceorientationabsolute: ((this: Window, ev: DeviceOrientationEvent) => any) | null; + onerror: OnErrorEventHandler; /** * @deprecated * @@ -41768,6 +41770,7 @@ declare var ondeviceorientation: ((this: Window, ev: DeviceOrientationEvent) => * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/deviceorientationabsolute_event) */ declare var ondeviceorientationabsolute: ((this: Window, ev: DeviceOrientationEvent) => any) | null; +declare var onerror: OnErrorEventHandler; /** * @deprecated * @@ -42148,8 +42151,6 @@ declare var ondurationchange: ((this: Window, ev: Event) => any) | null; declare var onemptied: ((this: Window, ev: Event) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/ended_event) */ declare var onended: ((this: Window, ev: Event) => any) | null; -/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/error_event) */ -declare var onerror: OnErrorEventHandler; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/focus_event) */ declare var onfocus: ((this: Window, ev: FocusEvent) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLFormElement/formdata_event) */ diff --git a/baselines/ts5.6/dom.generated.d.ts b/baselines/ts5.6/dom.generated.d.ts index a45b90495..33532bb53 100644 --- a/baselines/ts5.6/dom.generated.d.ts +++ b/baselines/ts5.6/dom.generated.d.ts @@ -15093,7 +15093,7 @@ interface GlobalEventHandlersEventMap { "durationchange": Event; "emptied": Event; "ended": Event; - "error": ErrorEvent; + "error": Event; "focus": FocusEvent; "focusin": FocusEvent; "focusout": FocusEvent; @@ -15234,7 +15234,7 @@ interface GlobalEventHandlers { /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/ended_event) */ onended: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/error_event) */ - onerror: OnErrorEventHandler; + onerror: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/focus_event) */ onfocus: ((this: GlobalEventHandlers, ev: FocusEvent) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLFormElement/formdata_event) */ @@ -39457,6 +39457,7 @@ interface WindowEventMap extends GlobalEventHandlersEventMap, WindowEventHandler "devicemotion": DeviceMotionEvent; "deviceorientation": DeviceOrientationEvent; "deviceorientationabsolute": DeviceOrientationEvent; + "error": ErrorEvent; "gamepadconnected": GamepadEvent; "gamepaddisconnected": GamepadEvent; "orientationchange": Event; @@ -39609,6 +39610,7 @@ interface Window extends EventTarget, AnimationFrameProvider, GlobalEventHandler * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/deviceorientationabsolute_event) */ ondeviceorientationabsolute: ((this: Window, ev: DeviceOrientationEvent) => any) | null; + onerror: OnErrorEventHandler; /** * @deprecated * @@ -41791,6 +41793,7 @@ declare var ondeviceorientation: ((this: Window, ev: DeviceOrientationEvent) => * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/deviceorientationabsolute_event) */ declare var ondeviceorientationabsolute: ((this: Window, ev: DeviceOrientationEvent) => any) | null; +declare var onerror: OnErrorEventHandler; /** * @deprecated * @@ -42171,8 +42174,6 @@ declare var ondurationchange: ((this: Window, ev: Event) => any) | null; declare var onemptied: ((this: Window, ev: Event) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/ended_event) */ declare var onended: ((this: Window, ev: Event) => any) | null; -/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/error_event) */ -declare var onerror: OnErrorEventHandler; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/focus_event) */ declare var onfocus: ((this: Window, ev: FocusEvent) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLFormElement/formdata_event) */ diff --git a/baselines/ts5.9/dom.generated.d.ts b/baselines/ts5.9/dom.generated.d.ts index ff1be1358..b5239d6ec 100644 --- a/baselines/ts5.9/dom.generated.d.ts +++ b/baselines/ts5.9/dom.generated.d.ts @@ -15093,7 +15093,7 @@ interface GlobalEventHandlersEventMap { "durationchange": Event; "emptied": Event; "ended": Event; - "error": ErrorEvent; + "error": Event; "focus": FocusEvent; "focusin": FocusEvent; "focusout": FocusEvent; @@ -15234,7 +15234,7 @@ interface GlobalEventHandlers { /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/ended_event) */ onended: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/error_event) */ - onerror: OnErrorEventHandler; + onerror: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/focus_event) */ onfocus: ((this: GlobalEventHandlers, ev: FocusEvent) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLFormElement/formdata_event) */ @@ -39457,6 +39457,7 @@ interface WindowEventMap extends GlobalEventHandlersEventMap, WindowEventHandler "devicemotion": DeviceMotionEvent; "deviceorientation": DeviceOrientationEvent; "deviceorientationabsolute": DeviceOrientationEvent; + "error": ErrorEvent; "gamepadconnected": GamepadEvent; "gamepaddisconnected": GamepadEvent; "orientationchange": Event; @@ -39609,6 +39610,7 @@ interface Window extends EventTarget, AnimationFrameProvider, GlobalEventHandler * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/deviceorientationabsolute_event) */ ondeviceorientationabsolute: ((this: Window, ev: DeviceOrientationEvent) => any) | null; + onerror: OnErrorEventHandler; /** * @deprecated * @@ -41791,6 +41793,7 @@ declare var ondeviceorientation: ((this: Window, ev: DeviceOrientationEvent) => * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/deviceorientationabsolute_event) */ declare var ondeviceorientationabsolute: ((this: Window, ev: DeviceOrientationEvent) => any) | null; +declare var onerror: OnErrorEventHandler; /** * @deprecated * @@ -42171,8 +42174,6 @@ declare var ondurationchange: ((this: Window, ev: Event) => any) | null; declare var onemptied: ((this: Window, ev: Event) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/ended_event) */ declare var onended: ((this: Window, ev: Event) => any) | null; -/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/error_event) */ -declare var onerror: OnErrorEventHandler; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/focus_event) */ declare var onfocus: ((this: Window, ev: FocusEvent) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLFormElement/formdata_event) */ diff --git a/inputfiles/overridingTypes.jsonc b/inputfiles/overridingTypes.jsonc index 207aeec45..d9b52f97c 100644 --- a/inputfiles/overridingTypes.jsonc +++ b/inputfiles/overridingTypes.jsonc @@ -427,9 +427,22 @@ // making it nullable breaks compatibility as it has historically been non-nullable in TS lib. // See the example in https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-parent. "nullable": false + }, + "onerror": { + "name": "onerror", + "overrideType": "OnErrorEventHandler", + "eventHandler": "error" } } }, + "events": { + "event": [ + { + "name": "error", + "type": "ErrorEvent" + } + ] + }, "methods": { "method": { "alert": { diff --git a/inputfiles/patches/events.kdl b/inputfiles/patches/events.kdl index 4d11ba797..a4349396f 100644 --- a/inputfiles/patches/events.kdl +++ b/inputfiles/patches/events.kdl @@ -29,7 +29,7 @@ interface-mixin GlobalEventHandlers { event dragover type=DragEvent event dragstart type=DragEvent event drop type=DragEvent - event error type=ErrorEvent + event error type=Event event focus type=FocusEvent event focusin type=FocusEvent event focusout type=FocusEvent @@ -76,7 +76,6 @@ interface-mixin GlobalEventHandlers { event transitionstart type=TransitionEvent event transitionend type=TransitionEvent event transitioncancel type=TransitionEvent - property onerror overrideType=OnErrorEventHandler } interface-mixin MessageEventTarget { diff --git a/src/build/emitter.ts b/src/build/emitter.ts index d09597bdc..1fc5598bf 100644 --- a/src/build/emitter.ts +++ b/src/build/emitter.ts @@ -856,7 +856,12 @@ export function emitWebIdl( // A covariant EventHandler is one that is defined in a parent interface as then redefined in current interface with a more specific argument types // These patterns are unsafe, and flagged as error under --strictFunctionTypes. // Here we know the property is already defined on the interface, we elide its declaration if the parent has the same handler defined + // Exception: if the property has an overrideType, we should emit it as an intentional override function isCovariantEventHandler(i: Browser.Interface, p: Browser.Property) { + // If this property has an explicit overrideType, emit it (it's an intentional override) + if (p.overrideType) { + return false; + } return ( isEventHandler(p) && iNameToEhParents[i.name].some((parent) => @@ -996,13 +1001,20 @@ export function emitWebIdl( prefix: string, emitScope: EmitScope, i: Browser.Interface, + emittedProperties?: Set, ) { if (i.properties) { mapToArray(i.properties.property) .filter((m) => matchScope(emitScope, m)) .filter((p) => !isCovariantEventHandler(i, p)) + .filter((p) => !emittedProperties || !emittedProperties.has(p.name)) .sort(compareName) - .forEach((p) => emitProperty(prefix, i, emitScope, p)); + .forEach((p) => { + emitProperty(prefix, i, emitScope, p); + if (emittedProperties) { + emittedProperties.add(p.name); + } + }); } } @@ -1148,11 +1160,12 @@ export function emitWebIdl( prefix: string, emitScope: EmitScope, i: Browser.Interface, + emittedProperties?: Set, ) { const conflictedMembers = extendConflictsBaseTypes[i.name] ? extendConflictsBaseTypes[i.name].memberNames : new Set(); - emitProperties(prefix, emitScope, i); + emitProperties(prefix, emitScope, i, emittedProperties); const methodPrefix = prefix.startsWith("declare var") ? "declare function " : ""; @@ -1164,13 +1177,21 @@ export function emitWebIdl( /// Emit all members of every interfaces at the root level. /// Called only once on the global polluter object - function emitAllMembers(i: Browser.Interface) { - emitMembers(/*prefix*/ "declare var ", "InstanceOnly", i); + function emitAllMembers( + i: Browser.Interface, + emittedProperties: Set = new Set(), + ) { + emitMembers( + /*prefix*/ "declare var ", + "InstanceOnly", + i, + emittedProperties, + ); for (const relatedIName of iNameToIDependList[i.name]) { const i = allInterfacesMap[relatedIName]; if (i) { - emitAllMembers(i); + emitAllMembers(i, emittedProperties); } } } diff --git a/unittests/files/onerror.ts b/unittests/files/onerror.ts new file mode 100644 index 000000000..a524c2761 --- /dev/null +++ b/unittests/files/onerror.ts @@ -0,0 +1,40 @@ +/** + * window.onerror works as intended with global event handler + */ +window.onerror = (message, src, lineno, colno, error) => { + if (message && src && lineno && colno && error) { + return; + } +}; + +const div: HTMLElement = document.createElement("div"); + +/** + * HTMLElement.onerror works with a single event arg, Event + */ +div.onerror = (event: Event) => { + if (event) { + return; + } +}; + +/** + * HTMLElement onerror is nullable + */ +div.onerror = null; + +const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + +/** + * SVGElement.onerror works with a single event arg, Event + */ +svg.onerror = (event: Event) => { + if (event) { + return; + } +}; + +/** + * SVGElement onerror is nullable + */ +svg.onerror = null; \ No newline at end of file From 818519cf161891a56ed28828acac72a0764f23e0 Mon Sep 17 00:00:00 2001 From: dandalf Date: Sun, 11 Jan 2026 13:35:15 -0700 Subject: [PATCH 2/6] added tests to eventlistener --- unittests/files/eventlistener.ts | 53 +++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/unittests/files/eventlistener.ts b/unittests/files/eventlistener.ts index 021afbc3c..e79677e90 100644 --- a/unittests/files/eventlistener.ts +++ b/unittests/files/eventlistener.ts @@ -1,9 +1,54 @@ -document.addEventListener("arbitrary_invalid_event", (ev) => { - return ev.returnValue; -}); - document.addEventListener("arbitrary_invalid_event", { handleEvent(ev) { return ev.returnValue; + }, +}); +const divElement: HTMLElement = document.createElement("div"); + +/** + * addEventListener works with a single event arg, Event + */ +divElement.addEventListener( + "click", + (event: Event) => { + if (event) { + return; + } + }, + false, +); +/** + * HTMLElement addEventListener works with a custom string and single event arg, Event + */ +divElement.addEventListener("beep", (event: Event) => { + if (event) { + return; + } +}); + +const svgElement = document.createElementNS( + "http://www.w3.org/2000/svg", + "svg", +); + +/** + * SVGElement addEventListener works with a single event arg, Event + */ +svgElement.addEventListener( + "click", + (event: Event) => { + if (event) { + return; + } + }, + false, +); + +/** + * SVGElement addEventListener works with a custom string and single event arg, Event + */ +svgElement.addEventListener("beep", (event: Event) => { + if (event) { + return; } }); From 3a50212f2dc8a0a407fa0e2a06b0a0caff195164 Mon Sep 17 00:00:00 2001 From: cosmic-pixel-painter Date: Sun, 11 Jan 2026 15:25:23 -0700 Subject: [PATCH 3/6] Update inputfiles/overridingTypes.jsonc Co-authored-by: Kagami Sascha Rosylight --- inputfiles/overridingTypes.jsonc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inputfiles/overridingTypes.jsonc b/inputfiles/overridingTypes.jsonc index d9b52f97c..bb2a6ea66 100644 --- a/inputfiles/overridingTypes.jsonc +++ b/inputfiles/overridingTypes.jsonc @@ -430,7 +430,7 @@ }, "onerror": { "name": "onerror", - "overrideType": "OnErrorEventHandler", + "type": "OnErrorEventHandler", "eventHandler": "error" } } From ce679c4b56a435c09337dfd833043befb2e05b6a Mon Sep 17 00:00:00 2001 From: dandalf Date: Sun, 11 Jan 2026 16:03:40 -0700 Subject: [PATCH 4/6] reverted pr suggestion --- inputfiles/overridingTypes.jsonc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inputfiles/overridingTypes.jsonc b/inputfiles/overridingTypes.jsonc index bb2a6ea66..d9b52f97c 100644 --- a/inputfiles/overridingTypes.jsonc +++ b/inputfiles/overridingTypes.jsonc @@ -430,7 +430,7 @@ }, "onerror": { "name": "onerror", - "type": "OnErrorEventHandler", + "overrideType": "OnErrorEventHandler", "eventHandler": "error" } } From f88a0bc43a93d10b5ea34ca311def0c91cbf52ab Mon Sep 17 00:00:00 2001 From: dandalf Date: Sun, 11 Jan 2026 19:09:29 -0700 Subject: [PATCH 5/6] got implementation to work with KDL, added comment to window.onerror --- baselines/dom.generated.d.ts | 2 ++ baselines/ts5.5/dom.generated.d.ts | 2 ++ baselines/ts5.6/dom.generated.d.ts | 2 ++ baselines/ts5.9/dom.generated.d.ts | 2 ++ inputfiles/overridingTypes.jsonc | 13 ------------- inputfiles/patches/events.kdl | 2 ++ 6 files changed, 10 insertions(+), 13 deletions(-) diff --git a/baselines/dom.generated.d.ts b/baselines/dom.generated.d.ts index a7f25ebc4..c29e71393 100644 --- a/baselines/dom.generated.d.ts +++ b/baselines/dom.generated.d.ts @@ -39613,6 +39613,7 @@ interface Window extends EventTarget, AnimationFrameProvider, GlobalEventHandler * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/deviceorientationabsolute_event) */ ondeviceorientationabsolute: ((this: Window, ev: DeviceOrientationEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/error_event) */ onerror: OnErrorEventHandler; /** * @deprecated @@ -41796,6 +41797,7 @@ declare var ondeviceorientation: ((this: Window, ev: DeviceOrientationEvent) => * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/deviceorientationabsolute_event) */ declare var ondeviceorientationabsolute: ((this: Window, ev: DeviceOrientationEvent) => any) | null; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/error_event) */ declare var onerror: OnErrorEventHandler; /** * @deprecated diff --git a/baselines/ts5.5/dom.generated.d.ts b/baselines/ts5.5/dom.generated.d.ts index 732061c66..4767e26e2 100644 --- a/baselines/ts5.5/dom.generated.d.ts +++ b/baselines/ts5.5/dom.generated.d.ts @@ -39587,6 +39587,7 @@ interface Window extends EventTarget, AnimationFrameProvider, GlobalEventHandler * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/deviceorientationabsolute_event) */ ondeviceorientationabsolute: ((this: Window, ev: DeviceOrientationEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/error_event) */ onerror: OnErrorEventHandler; /** * @deprecated @@ -41770,6 +41771,7 @@ declare var ondeviceorientation: ((this: Window, ev: DeviceOrientationEvent) => * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/deviceorientationabsolute_event) */ declare var ondeviceorientationabsolute: ((this: Window, ev: DeviceOrientationEvent) => any) | null; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/error_event) */ declare var onerror: OnErrorEventHandler; /** * @deprecated diff --git a/baselines/ts5.6/dom.generated.d.ts b/baselines/ts5.6/dom.generated.d.ts index 33532bb53..f5b0586db 100644 --- a/baselines/ts5.6/dom.generated.d.ts +++ b/baselines/ts5.6/dom.generated.d.ts @@ -39610,6 +39610,7 @@ interface Window extends EventTarget, AnimationFrameProvider, GlobalEventHandler * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/deviceorientationabsolute_event) */ ondeviceorientationabsolute: ((this: Window, ev: DeviceOrientationEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/error_event) */ onerror: OnErrorEventHandler; /** * @deprecated @@ -41793,6 +41794,7 @@ declare var ondeviceorientation: ((this: Window, ev: DeviceOrientationEvent) => * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/deviceorientationabsolute_event) */ declare var ondeviceorientationabsolute: ((this: Window, ev: DeviceOrientationEvent) => any) | null; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/error_event) */ declare var onerror: OnErrorEventHandler; /** * @deprecated diff --git a/baselines/ts5.9/dom.generated.d.ts b/baselines/ts5.9/dom.generated.d.ts index b5239d6ec..294332547 100644 --- a/baselines/ts5.9/dom.generated.d.ts +++ b/baselines/ts5.9/dom.generated.d.ts @@ -39610,6 +39610,7 @@ interface Window extends EventTarget, AnimationFrameProvider, GlobalEventHandler * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/deviceorientationabsolute_event) */ ondeviceorientationabsolute: ((this: Window, ev: DeviceOrientationEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/error_event) */ onerror: OnErrorEventHandler; /** * @deprecated @@ -41793,6 +41794,7 @@ declare var ondeviceorientation: ((this: Window, ev: DeviceOrientationEvent) => * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/deviceorientationabsolute_event) */ declare var ondeviceorientationabsolute: ((this: Window, ev: DeviceOrientationEvent) => any) | null; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/error_event) */ declare var onerror: OnErrorEventHandler; /** * @deprecated diff --git a/inputfiles/overridingTypes.jsonc b/inputfiles/overridingTypes.jsonc index d9b52f97c..207aeec45 100644 --- a/inputfiles/overridingTypes.jsonc +++ b/inputfiles/overridingTypes.jsonc @@ -427,22 +427,9 @@ // making it nullable breaks compatibility as it has historically been non-nullable in TS lib. // See the example in https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-parent. "nullable": false - }, - "onerror": { - "name": "onerror", - "overrideType": "OnErrorEventHandler", - "eventHandler": "error" } } }, - "events": { - "event": [ - { - "name": "error", - "type": "ErrorEvent" - } - ] - }, "methods": { "method": { "alert": { diff --git a/inputfiles/patches/events.kdl b/inputfiles/patches/events.kdl index a4349396f..0a790de2b 100644 --- a/inputfiles/patches/events.kdl +++ b/inputfiles/patches/events.kdl @@ -108,6 +108,8 @@ interface Window { event gamepadconnected type=GamepadEvent event gamepaddisconnected type=GamepadEvent event DOMContentLoaded type=Event + event error type=ErrorEvent + property onerror overrideType="OnErrorEventHandler" mdnUrl="https://developer.mozilla.org/docs/Web/API/Window/error_event" } interface WorkerGlobalScope { From 6ad91bbc9183662a0f9916e23fcc26df3533414d Mon Sep 17 00:00:00 2001 From: dandalf Date: Mon, 12 Jan 2026 20:22:08 -0700 Subject: [PATCH 6/6] updated emitter since change comes from kdl now --- src/build/emitter.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/build/emitter.ts b/src/build/emitter.ts index 1fc5598bf..89486c319 100644 --- a/src/build/emitter.ts +++ b/src/build/emitter.ts @@ -856,12 +856,7 @@ export function emitWebIdl( // A covariant EventHandler is one that is defined in a parent interface as then redefined in current interface with a more specific argument types // These patterns are unsafe, and flagged as error under --strictFunctionTypes. // Here we know the property is already defined on the interface, we elide its declaration if the parent has the same handler defined - // Exception: if the property has an overrideType, we should emit it as an intentional override function isCovariantEventHandler(i: Browser.Interface, p: Browser.Property) { - // If this property has an explicit overrideType, emit it (it's an intentional override) - if (p.overrideType) { - return false; - } return ( isEventHandler(p) && iNameToEhParents[i.name].some((parent) =>