From 71dbcc26cc28d040e13d31bf51d68d18b4dece2b Mon Sep 17 00:00:00 2001 From: Wojciech Maj Date: Tue, 28 Oct 2025 12:30:49 +0100 Subject: [PATCH] Allow document.fonts to be passed to useEventListener --- src/useEventListener.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/useEventListener.ts b/src/useEventListener.ts index aa8f4e8..5f30e25 100644 --- a/src/useEventListener.ts +++ b/src/useEventListener.ts @@ -6,7 +6,7 @@ type GlobalAndWindowEventHandlersEventMap = WindowEventHandlersEventMap & /** * Adds event listener to a given element. * - * @param {Element | Window | Document} [element] Element to attach the listener to + * @param {Element | Window | Document | FontFaceSet | null} [element] Element to attach the listener to * @param {string} type Event type * @param {EventListenerOrEventListenerObject} listener Event listener * @returns {void} @@ -26,8 +26,13 @@ export default function useEventListener( type: U, listener: (event: DocumentEventMap[U]) => void, ): void; +export default function useEventListener( + element: FontFaceSet | null, + type: U, + listener: (event: FontFaceSetEventMap[U]) => void, +): void; export default function useEventListener( - element: Element | Window | Document | null, + element: Element | Window | Document | FontFaceSet | null, type: string, listener: EventListenerOrEventListenerObject | ((event: Event) => void), ): void { -- 2.51.2