From ee5bb84bc5a6e4ac51711e48442df71f353f933e Mon Sep 17 00:00:00 2001 From: RKS Date: Tue, 13 Oct 2026 14:57:26 -0400 Subject: [PATCH 1/2] Type command event handlers as CommandEvent --- baselines/dom.generated.d.ts | 6 +++--- baselines/ts5.5/dom.generated.d.ts | 6 +++--- baselines/ts5.6/dom.generated.d.ts | 6 +++--- baselines/ts5.9/dom.generated.d.ts | 6 +++--- inputfiles/overridingTypes.jsonc | 10 ++++++++++ unittests/files/command-event.ts | 20 ++++++++++++++++++++ 6 files changed, 42 insertions(+), 12 deletions(-) create mode 100644 unittests/files/command-event.ts diff --git a/baselines/dom.generated.d.ts b/baselines/dom.generated.d.ts index f543d0f63..2140495e2 100644 --- a/baselines/dom.generated.d.ts +++ b/baselines/dom.generated.d.ts @@ -17222,7 +17222,7 @@ interface GlobalEventHandlersEventMap { "change": Event; "click": PointerEvent; "close": Event; - "command": Event; + "command": CommandEvent; "compositionend": CompositionEvent; "compositionstart": CompositionEvent; "compositionupdate": CompositionEvent; @@ -17348,7 +17348,7 @@ interface GlobalEventHandlers { /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLDialogElement/close_event) */ onclose: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/command_event) */ - oncommand: ((this: GlobalEventHandlers, ev: Event) => any) | null; + oncommand: ((this: GlobalEventHandlers, ev: CommandEvent) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement/contextlost_event) */ oncontextlost: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/contextmenu_event) */ @@ -44734,7 +44734,7 @@ declare var onclick: ((this: Window, ev: PointerEvent) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLDialogElement/close_event) */ declare var onclose: ((this: Window, ev: Event) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/command_event) */ -declare var oncommand: ((this: Window, ev: Event) => any) | null; +declare var oncommand: ((this: Window, ev: CommandEvent) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement/contextlost_event) */ declare var oncontextlost: ((this: Window, ev: Event) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/contextmenu_event) */ diff --git a/baselines/ts5.5/dom.generated.d.ts b/baselines/ts5.5/dom.generated.d.ts index 2594d311f..45ec977fd 100644 --- a/baselines/ts5.5/dom.generated.d.ts +++ b/baselines/ts5.5/dom.generated.d.ts @@ -17208,7 +17208,7 @@ interface GlobalEventHandlersEventMap { "change": Event; "click": PointerEvent; "close": Event; - "command": Event; + "command": CommandEvent; "compositionend": CompositionEvent; "compositionstart": CompositionEvent; "compositionupdate": CompositionEvent; @@ -17334,7 +17334,7 @@ interface GlobalEventHandlers { /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLDialogElement/close_event) */ onclose: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/command_event) */ - oncommand: ((this: GlobalEventHandlers, ev: Event) => any) | null; + oncommand: ((this: GlobalEventHandlers, ev: CommandEvent) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement/contextlost_event) */ oncontextlost: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/contextmenu_event) */ @@ -44708,7 +44708,7 @@ declare var onclick: ((this: Window, ev: PointerEvent) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLDialogElement/close_event) */ declare var onclose: ((this: Window, ev: Event) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/command_event) */ -declare var oncommand: ((this: Window, ev: Event) => any) | null; +declare var oncommand: ((this: Window, ev: CommandEvent) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement/contextlost_event) */ declare var oncontextlost: ((this: Window, ev: Event) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/contextmenu_event) */ diff --git a/baselines/ts5.6/dom.generated.d.ts b/baselines/ts5.6/dom.generated.d.ts index a9f3c2fc4..aca3db87f 100644 --- a/baselines/ts5.6/dom.generated.d.ts +++ b/baselines/ts5.6/dom.generated.d.ts @@ -17219,7 +17219,7 @@ interface GlobalEventHandlersEventMap { "change": Event; "click": PointerEvent; "close": Event; - "command": Event; + "command": CommandEvent; "compositionend": CompositionEvent; "compositionstart": CompositionEvent; "compositionupdate": CompositionEvent; @@ -17345,7 +17345,7 @@ interface GlobalEventHandlers { /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLDialogElement/close_event) */ onclose: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/command_event) */ - oncommand: ((this: GlobalEventHandlers, ev: Event) => any) | null; + oncommand: ((this: GlobalEventHandlers, ev: CommandEvent) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement/contextlost_event) */ oncontextlost: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/contextmenu_event) */ @@ -44731,7 +44731,7 @@ declare var onclick: ((this: Window, ev: PointerEvent) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLDialogElement/close_event) */ declare var onclose: ((this: Window, ev: Event) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/command_event) */ -declare var oncommand: ((this: Window, ev: Event) => any) | null; +declare var oncommand: ((this: Window, ev: CommandEvent) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement/contextlost_event) */ declare var oncontextlost: ((this: Window, ev: Event) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/contextmenu_event) */ diff --git a/baselines/ts5.9/dom.generated.d.ts b/baselines/ts5.9/dom.generated.d.ts index 83e861452..b0dba0280 100644 --- a/baselines/ts5.9/dom.generated.d.ts +++ b/baselines/ts5.9/dom.generated.d.ts @@ -17219,7 +17219,7 @@ interface GlobalEventHandlersEventMap { "change": Event; "click": PointerEvent; "close": Event; - "command": Event; + "command": CommandEvent; "compositionend": CompositionEvent; "compositionstart": CompositionEvent; "compositionupdate": CompositionEvent; @@ -17345,7 +17345,7 @@ interface GlobalEventHandlers { /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLDialogElement/close_event) */ onclose: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/command_event) */ - oncommand: ((this: GlobalEventHandlers, ev: Event) => any) | null; + oncommand: ((this: GlobalEventHandlers, ev: CommandEvent) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement/contextlost_event) */ oncontextlost: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/contextmenu_event) */ @@ -44731,7 +44731,7 @@ declare var onclick: ((this: Window, ev: PointerEvent) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLDialogElement/close_event) */ declare var onclose: ((this: Window, ev: Event) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/command_event) */ -declare var oncommand: ((this: Window, ev: Event) => any) | null; +declare var oncommand: ((this: Window, ev: CommandEvent) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement/contextlost_event) */ declare var oncontextlost: ((this: Window, ev: Event) => any) | null; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/contextmenu_event) */ diff --git a/inputfiles/overridingTypes.jsonc b/inputfiles/overridingTypes.jsonc index b20f538ba..b2aac6a78 100644 --- a/inputfiles/overridingTypes.jsonc +++ b/inputfiles/overridingTypes.jsonc @@ -1,6 +1,16 @@ { "mixins": { "mixin": { + "GlobalEventHandlers": { + "events": { + "event": [ + { + "name": "command", + "type": "CommandEvent" + } + ] + } + }, "Animatable": { "methods": { "method": { diff --git a/unittests/files/command-event.ts b/unittests/files/command-event.ts new file mode 100644 index 000000000..7cae3c9df --- /dev/null +++ b/unittests/files/command-event.ts @@ -0,0 +1,20 @@ +document.body.addEventListener("command", (event) => { + const command: string = event.command; + const source: Element | null = event.source; +}); + +document.body.oncommand = (event) => { + const command: string = event.command; +}; + +document.addEventListener("command", (event) => { + const command: string = event.command; +}); + +window.oncommand = (event) => { + const command: string = event.command; +}; + +oncommand = (event) => { + const command: string = event.command; +}; From 3229bab902b6d472aa7ad058cdc6c8cb479aa96d Mon Sep 17 00:00:00 2001 From: RKS Date: Wed, 14 Oct 2026 12:15:18 -0400 Subject: [PATCH 2/2] Move command event mapping to the KDL event patch --- inputfiles/overridingTypes.jsonc | 10 ---------- inputfiles/patches/events.kdl | 1 + unittests/files/command-event.ts | 15 +++++++++++++++ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/inputfiles/overridingTypes.jsonc b/inputfiles/overridingTypes.jsonc index b2aac6a78..b20f538ba 100644 --- a/inputfiles/overridingTypes.jsonc +++ b/inputfiles/overridingTypes.jsonc @@ -1,16 +1,6 @@ { "mixins": { "mixin": { - "GlobalEventHandlers": { - "events": { - "event": [ - { - "name": "command", - "type": "CommandEvent" - } - ] - } - }, "Animatable": { "methods": { "method": { diff --git a/inputfiles/patches/events.kdl b/inputfiles/patches/events.kdl index 4d11ba797..9081bbf22 100644 --- a/inputfiles/patches/events.kdl +++ b/inputfiles/patches/events.kdl @@ -17,6 +17,7 @@ interface-mixin GlobalEventHandlers { event beforetoggle type=ToggleEvent event blur type=FocusEvent event click type=PointerEvent + event command type=CommandEvent event compositionend type=CompositionEvent event compositionstart type=CompositionEvent event compositionupdate type=CompositionEvent diff --git a/unittests/files/command-event.ts b/unittests/files/command-event.ts index 7cae3c9df..89e8b48d5 100644 --- a/unittests/files/command-event.ts +++ b/unittests/files/command-event.ts @@ -1,20 +1,35 @@ document.body.addEventListener("command", (event) => { + const commandEvent: CommandEvent = event; const command: string = event.command; const source: Element | null = event.source; }); document.body.oncommand = (event) => { + const commandEvent: CommandEvent = event; const command: string = event.command; }; document.addEventListener("command", (event) => { + const commandEvent: CommandEvent = event; const command: string = event.command; }); window.oncommand = (event) => { + const commandEvent: CommandEvent = event; const command: string = event.command; }; oncommand = (event) => { + const commandEvent: CommandEvent = event; const command: string = event.command; }; + +window.addEventListener("command", (event) => { + const commandEvent: CommandEvent = event; + const source: Element | null = event.source; +}); + +addEventListener("command", (event) => { + const commandEvent: CommandEvent = event; + const command: string = event.command; +});