-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correctly remove navigation callbacks when returning function in…
… onNavigate (#13241) Do that by switching to a Set and keeping a stable reference across call sites. fixes #13240
- Loading branch information
Showing
6 changed files
with
72 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@sveltejs/kit': patch | ||
--- | ||
|
||
fix: correctly remove navigation callbacks when returning function in onNavigate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...pps/basics/src/routes/navigation-lifecycle/after-navigate-properly-removed/+layout.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<script> | ||
import { onNavigate } from '$app/navigation'; | ||
let { children } = $props(); | ||
onNavigate(() => { | ||
return () => {}; | ||
}); | ||
</script> | ||
|
||
{@render children()} |
20 changes: 20 additions & 0 deletions
20
...pps/basics/src/routes/navigation-lifecycle/after-navigate-properly-removed/a/+page.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<script> | ||
import { afterNavigate } from '$app/navigation'; | ||
afterNavigate(() => { | ||
console.log('after navigate called'); | ||
/** | ||
* @type {HTMLElement} | ||
*/ | ||
const el = document.querySelector('.nav-lifecycle-after-nav-removed-test-target'); | ||
if (el) { | ||
el.innerText = 'true'; | ||
} | ||
}); | ||
</script> | ||
|
||
<h1>/A</h1> | ||
<a href="/navigation-lifecycle/after-navigate-properly-removed/a">/a</a> | ||
<a href="/navigation-lifecycle/after-navigate-properly-removed/b">/b</a> |
7 changes: 7 additions & 0 deletions
7
...pps/basics/src/routes/navigation-lifecycle/after-navigate-properly-removed/b/+page.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<h1>/B</h1> | ||
<div> | ||
was called: | ||
<span class="nav-lifecycle-after-nav-removed-test-target">false</span> | ||
</div> | ||
<a href="/navigation-lifecycle/after-navigate-properly-removed/a">/a</a> | ||
<a href="/navigation-lifecycle/after-navigate-properly-removed/b">/b</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters