diff --git a/packages/runed/src/lib/functions/useActiveElement/useActiveElement.svelte.ts b/packages/runed/src/lib/functions/useActiveElement/useActiveElement.svelte.ts index a1038a18..72bf6f2c 100644 --- a/packages/runed/src/lib/functions/useActiveElement/useActiveElement.svelte.ts +++ b/packages/runed/src/lib/functions/useActiveElement/useActiveElement.svelte.ts @@ -1,7 +1,7 @@ -import { documentDefined } from "../../internal/utils/defined.js"; +import { isBrowser } from "$lib/internal/utils/browser.js"; export function useActiveElement(): { value: Readonly } { - const activeElement = $state({ value: documentDefined() ? document.activeElement : null }); + const activeElement = $state({ value: isBrowser() ? document.activeElement : null }); function onFocusChange() { activeElement.value = document.activeElement; diff --git a/packages/runed/src/lib/internal/utils/defined.ts b/packages/runed/src/lib/internal/utils/browser.ts similarity index 54% rename from packages/runed/src/lib/internal/utils/defined.ts rename to packages/runed/src/lib/internal/utils/browser.ts index 606dbddb..12424eba 100644 --- a/packages/runed/src/lib/internal/utils/defined.ts +++ b/packages/runed/src/lib/internal/utils/browser.ts @@ -1,3 +1,3 @@ -export function documentDefined() { +export function isBrowser() { return typeof document !== "undefined"; }