Skip to content

Commit

Permalink
Fix ts error
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesKlauss committed Nov 2, 2024
1 parent 4668ebb commit 1f95c28
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,21 @@ export function isHotkeyEnabledOnTag(
): boolean {
const {target, composed} = event;

let targetTagName;
let targetTagName: string | null = null

if (isCustomElement(target as HTMLElement) && composed) {
targetTagName = event.composedPath()[0] && (event.composedPath()[0] as HTMLElement).tagName;
} else {
targetTagName = target && (target as HTMLElement).tagName;
}

if (isReadonlyArray(enabledOnTags)) {
return Boolean(
targetTagName && enabledOnTags && enabledOnTags.some((tag) => tag.toLowerCase() === targetTagName.toLowerCase())
)
}

return Boolean(targetTagName && enabledOnTags && enabledOnTags === true)
return Boolean(targetTagName && enabledOnTags && enabledOnTags)
}

export function isCustomElement(element: HTMLElement): boolean {
Expand Down

0 comments on commit 1f95c28

Please sign in to comment.