Skip to content

Commit

Permalink
fix: SPA hydration could cause errors for certain anchors
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobrosenberg committed Jan 22, 2025
1 parent a3358ea commit 9c2e4a2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/runtime/decorators/AnchorDecorator.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/** @type {(parent: Node, anchor?: Node)=>any} */
export let onMount = x => x
const isSpa = !import.meta.env.ROUTIFY_SSR_ENABLE
const isCsr = typeof window !== 'undefined'
/** @type {HTMLElement} */
let elem
Expand Down Expand Up @@ -108,14 +108,14 @@
<slot />
{:else}
<!-- parent, firstChild or custom -->
{#if !mounted && isSpa}
{#if !mounted && isCsr}
<div data-routify-anchor-locator class="anchor" bind:this={elem} {...$$restProps}>
<!-- routify anchor locator -->
</div>
{/if}
<slot />

{#if !mounted && isSpa}
{#if !mounted && isCsr}
<div class="anchor-backstop" data-routify-anchor-backstop>
<!-- routify anchor backstop -->
</div>
Expand Down

0 comments on commit 9c2e4a2

Please sign in to comment.