Skip to content

Commit

Permalink
fix: destory container undefined (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
zzxming authored Jan 12, 2025
1 parent e46086a commit ad809dc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export interface TooltipInstance {
hide: () => void;
show: () => void;
}
let tooltipContainer: HTMLElement;
let tooltipContainer: HTMLElement | undefined;
export const createTooltip = (target: HTMLElement, options: Partial<TooltipOptions> = {}): TooltipInstance | null => {
let {
msg = '',
Expand Down Expand Up @@ -144,7 +144,7 @@ export const createTooltip = (target: HTMLElement, options: Partial<TooltipOptio
}
if (cleanup) cleanup();
tooltip.remove();
if (tooltipContainer.children.length <= 0) {
if (tooltipContainer && tooltipContainer.children.length <= 0) {
tooltipContainer.remove();
}
};
Expand Down

0 comments on commit ad809dc

Please sign in to comment.