From 00755c5a670bc6935b7e0243724e1e48bcba4d67 Mon Sep 17 00:00:00 2001 From: "Thomas G. Lopes" <26071571+TGlide@users.noreply.github.com> Date: Sat, 13 Apr 2024 17:00:20 +0100 Subject: [PATCH] small updates --- .../lib/functions/useActiveElement/useActiveElement.svelte.ts | 4 ++-- .../runed/src/lib/internal/utils/{defined.ts => browser.ts} | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename packages/runed/src/lib/internal/utils/{defined.ts => browser.ts} (54%) 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"; }