Skip to content

Commit 7152fdf

Browse files
committed
feat: add support for globalThis in event handling functions
1 parent e395d5b commit 7152fdf

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

types/__tests__/type-tests.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@ export function eventTest() {
210210
}
211211
fireEvent.click(element.firstChild)
212212

213+
// GlobalThis
214+
fireEvent.click(globalThis)
215+
const globalThisEvent = createEvent('customEvent', globalThis)
216+
fireEvent(globalThis, globalThisEvent)
217+
213218
// Custom event
214219
const customEvent = createEvent('customEvent', element)
215220
fireEvent(element, customEvent)

types/events.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,24 +92,24 @@ export type EventType =
9292
| 'pageShow'
9393

9494
export type FireFunction = (
95-
element: Document | Element | Window | Node,
95+
element: Document | Element | Window | Node | GlobalThis,
9696
event: Event,
9797
) => boolean
9898
export type FireObject = {
9999
[K in EventType]: (
100-
element: Document | Element | Window | Node,
100+
element: Document | Element | Window | Node | GlobalThis,
101101
options?: {},
102102
) => boolean
103103
}
104104
export type CreateFunction = (
105105
eventName: string,
106-
node: Document | Element | Window | Node,
106+
node: Document | Element | Window | Node | GlobalThis,
107107
init?: {},
108108
options?: {EventType?: string; defaultInit?: {}},
109109
) => Event
110110
export type CreateObject = {
111111
[K in EventType]: (
112-
element: Document | Element | Window | Node,
112+
element: Document | Element | Window | Node | GlobalThis,
113113
options?: {},
114114
) => Event
115115
}

0 commit comments

Comments
 (0)