Skip to content

Commit 391adec

Browse files
committed
fix: validations
1 parent 709ab62 commit 391adec

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/lib/actions/portal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { Action } from 'svelte/action';
33

44
export type PortalConfig = string | HTMLElement | undefined;
55

6-
export const portal: Action<HTMLElement, PortalConfig> = (el, target = 'body') => {
6+
export const portal: Action<HTMLElement, PortalConfig> = (el, target: PortalConfig = 'body') => {
77
let targetEl;
88

99
async function update(newTarget: PortalConfig) {
@@ -17,7 +17,7 @@ export const portal: Action<HTMLElement, PortalConfig> = (el, target = 'body') =
1717
if (targetEl === null) {
1818
throw new Error(`No element found matching css selector: "${target}"`);
1919
}
20-
} else if (target instanceof HTMLElement) {
20+
} else if (typeof target === 'object' && target instanceof HTMLElement) {
2121
targetEl = target;
2222
} else {
2323
throw new TypeError(

src/lib/actions/tooltip.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Action } from 'svelte/action';
2+
import type { Instance } from 'tippy.js';
23
import type { Props as TippyProps } from 'tippy.js';
34
import tippy from 'tippy.js';
45

@@ -7,7 +8,8 @@ type Props = TippyProps & {
78
};
89

910
export const tooltip: Action<HTMLElement, Partial<Props>> = (node, config) => {
10-
const instance = tippy(node, config);
11+
const tippyInstance = tippy(node, config);
12+
const instance: Instance = Array.isArray(tippyInstance) ? tippyInstance[0] : tippyInstance;
1113
if (config.disabled) instance.disable();
1214

1315
return {

vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineConfig } from 'vite';
1+
import { defineConfig } from 'vitest/config';
22
import { sveltekit } from '@sveltejs/kit/vite';
33
import { sentrySvelteKit } from '@sentry/sveltekit';
44
import { svelteTesting } from '@testing-library/svelte/vite';

0 commit comments

Comments
 (0)