Skip to content
This repository was archived by the owner on Apr 19, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Tooltip.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface TooltipProps
container?: ContainerType;
isOpen?: boolean;
placement?: TooltipPlacement;
target: string | HTMLElement;
target: string | Element;
}

export default class Tooltip extends SvelteComponentTyped<
Expand Down
12 changes: 6 additions & 6 deletions src/Tooltip.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

const open = () => (isOpen = true);
const close = () => (isOpen = false);

onMount(registerEventListeners);
onDestroy(unregisterEventListeners);

Expand All @@ -59,16 +59,16 @@
return;
}

// Check if target is HTMLElement
// Check if target is Element
try {
if (target instanceof HTMLElement) {
if (target instanceof Element) {
targetEl = target;
}
} catch (e) {
// fails on SSR
}

// If targetEl has not been found yet
// If targetEl has not been found yet
if (targetEl == null) {
// Check if target can be found via querySelector
try {
Expand All @@ -78,7 +78,7 @@
// fails on SSR
}
}

// If we've found targetEl
if (targetEl) {
targetEl.addEventListener('mouseover', open);
Expand All @@ -88,7 +88,7 @@
}
}

function unregisterEventListeners() {
function unregisterEventListeners() {
if (targetEl) {
targetEl.removeEventListener('mouseover', open);
targetEl.removeEventListener('mouseleave', close);
Expand Down