-
-
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] Prevent rerender when route state did not change (#5654)
* [fix] Prevent rerender when route state did not change Fixes #3732 * adjust code to fix only session case, tests * format * fix test expectation Co-authored-by: Simon Holthausen <[email protected]>
- Loading branch information
1 parent
66d17af
commit 8cba6ba
Showing
6 changed files
with
69 additions
and
2 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 | ||
--- | ||
|
||
Prevent rerender when route state did not change |
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
23 changes: 23 additions & 0 deletions
23
packages/kit/test/apps/basics/src/routes/load/change-detection/session/unused.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,23 @@ | ||
<script context="module"> | ||
/** @type {import('@sveltejs/kit').Load} */ | ||
export async function load() { | ||
return { | ||
props: { | ||
// Needs to be an object, else Svelte will do by-value-comparison and skip rerender | ||
obj: {} | ||
} | ||
}; | ||
} | ||
</script> | ||
|
||
<script> | ||
import { session } from '$app/stores'; | ||
/** @type {any} */ | ||
export let obj; | ||
let count = 0; | ||
$: obj && count++; | ||
</script> | ||
|
||
<h2>{count}</h2> | ||
<button on:click={() => ($session.calls = 123)}>Update $session</button> |
24 changes: 24 additions & 0 deletions
24
packages/kit/test/apps/basics/src/routes/load/change-detection/session/used.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,24 @@ | ||
<script context="module"> | ||
/** @type {import('@sveltejs/kit').Load} */ | ||
export async function load({ session }) { | ||
session; | ||
return { | ||
props: { | ||
// Needs to be an object, else Svelte will do by-value-comparison and skip rerender | ||
obj: {} | ||
} | ||
}; | ||
} | ||
</script> | ||
|
||
<script> | ||
import { session } from '$app/stores'; | ||
/** @type {any} */ | ||
export let obj; | ||
let count = 0; | ||
$: obj && count++; | ||
</script> | ||
|
||
<h2>{count}</h2> | ||
<button on:click={() => ($session.calls = 123)}>Update $session</button> |
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
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