Skip to content

Commit

Permalink
fix: ssr build error
Browse files Browse the repository at this point in the history
  • Loading branch information
zzxming committed Aug 2, 2024
1 parent 1c3fecc commit ddd0cc7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/directives/tooltip/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ const distance = 4;
type ToolTipElement = HTMLElement & { [tooltipKey]: HTMLElement };
type ToolTipOptions = string;

let tooltipWrapper: HTMLElement;
const { nextZIndex } = useZIndex();
const [, bem] = useBem('tooltip');

const tooltipWrapper = document.createElement('div');
tooltipWrapper.className = bem.be('wrapper');
document.body.appendChild(tooltipWrapper);

const directions = ['top', 'right', 'bottom', 'left'] as const;
const getValidDirection = (val: any): typeof directions[number] => {
if (!directions.includes(val)) {
Expand Down Expand Up @@ -114,6 +111,11 @@ const updateTooltipValue = (el: ToolTipElement, binding: DirectiveBinding<ToolTi
el.dataset.direction = getValidDirection(binding.arg || '');
};
const createTooltip = (el: ToolTipElement, binding: DirectiveBinding<ToolTipOptions>) => {
if (!tooltipWrapper) {
tooltipWrapper = document.createElement('div');
tooltipWrapper.className = bem.be('wrapper');
document.body.appendChild(tooltipWrapper);
}
const tooltipContent = document.createElement('div');
tooltipContent.className = `${bem.b()} ${bem.bm('hidden')}`;
const tooltipText = document.createElement('span');
Expand Down

0 comments on commit ddd0cc7

Please sign in to comment.