Skip to content

Commit

Permalink
fix: get rid of $app/environment again
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakeii committed Oct 28, 2022
1 parent 3e5418e commit 0f4887f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/lib/Popdown.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import { portal } from 'svelte-portal';
import { type Writable, writable } from 'svelte/store';
const isBrowser = !import.meta.env.SSR;
export let contentClass = '';
export let position = 'outer-bottom inner-left';
export let target: string | HTMLElement = document ? (document.scrollingElement as HTMLElement) : 'body';
export let target: string | HTMLElement = isBrowser ? (document.scrollingElement as HTMLElement) : 'body';
export let showContent = false;
export let calcLeft: null | CalcPosition = null;
export let calcTop: null | CalcPosition = null;
Expand All @@ -21,13 +23,13 @@
let targetElement: Writable<HTMLElement> = writable();
const updateTargetElement = (target: string | HTMLElement): void => {
if (document && typeof target === 'string') {
if (isBrowser && typeof target === 'string') {
const query = document.querySelector<HTMLElement>(target);
if (!query) {
throw new Error(`Could not find target element: ${target}`);
}
$targetElement = query;
} else if (document && target instanceof HTMLElement) {
} else if (isBrowser && target instanceof HTMLElement) {
$targetElement = target;
}
};
Expand Down

0 comments on commit 0f4887f

Please sign in to comment.