Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix] do not call server and update page.data unnecessarily (#6311)
* [fix] do not call server and update page.data unnecessarily Fixes #6201 Fixes #6286 * use ~ trick * remove rerun behavior from root test layout so we can properly test some scenarios * tabs * if page doesnt exist yet, data definitely changed * tweak Co-authored-by: Rich Harris <hello@rich-harris.dev>
- Loading branch information
1 parent
cbeb13a
commit 6a6ab8f
Showing
14 changed files
with
122 additions
and
60 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] do not call server and update `$page.data` unnecessarily |
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
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
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
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,9 @@ | ||
import { error } from '@sveltejs/kit'; | ||
|
||
/** @type {import('@sveltejs/kit').Load} */ | ||
export async function load({ fetch, url }) { | ||
if (url.pathname.startsWith('/errors/error-in-layout')) { | ||
const res = await fetch('/errors/error-in-layout/non-existent'); | ||
throw error(res.status); | ||
} | ||
} |
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 @@ | ||
<slot />; |
14 changes: 14 additions & 0 deletions
14
packages/kit/test/apps/basics/src/routes/store/data/unchanged/+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,14 @@ | ||
<script> | ||
import { page } from '$app/stores'; | ||
let previous = $page.data; | ||
let count = 0; | ||
$: { | ||
if (previous !== $page.data) { | ||
count++; | ||
} | ||
} | ||
</script> | ||
|
||
<p>$page.data was updated {count} time(s)</p> | ||
<a href="/store/data/unchanged/a">a</a> | ||
<a href="/store/data/unchanged/b">b</a> |
1 change: 1 addition & 0 deletions
1
packages/kit/test/apps/basics/src/routes/store/data/unchanged/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 @@ | ||
Page A |
1 change: 1 addition & 0 deletions
1
packages/kit/test/apps/basics/src/routes/store/data/unchanged/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 @@ | ||
Page B |
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