Skip to content

Commit

Permalink
Fix return type of interaction resolver not being precise enough
Browse files Browse the repository at this point in the history
  • Loading branch information
platz1de committed Oct 15, 2024
1 parent 7d5c42b commit 76c3838
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/ui/UIEventResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ const subscribers: {
[InteractionType.HOVER]: new Map()
};

export function resolveInteraction(element: HTMLElement | null, type: InteractionType): { id: string, listener: Omit<InteractionListeners[InteractionType], "test"> } | null {
/**
* Resolves the interaction listener for the given element.
* Elements propagate up the DOM tree until a listener is found.
* @param element The element to resolve the listener for
* @param type The type of listener to resolve
*/
export function resolveInteraction<T extends InteractionType>(element: HTMLElement | null, type: T): { id: string, listener: Omit<InteractionListeners[T], "test"> } | null {
if (!element || element.id === "" || !subscribers[type].has(element.id)) {
if (element && element.parentElement) {
return resolveInteraction(element.parentElement, type);
Expand Down

0 comments on commit 76c3838

Please sign in to comment.