-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add onNavigate
lifecycle function, to enable view transitions
#9605
Merged
Merged
Changes from 9 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
a91064e
group navigation lifecycle tests
fb3f63b
group navigation lifecycle test routes
a993dcb
add failing onNavigate test
46a24bf
add an onNavigate lifecycle function
e0b6849
Update packages/kit/test/apps/basics/test/cross-platform/client.test.js
Rich-Harris 79ae0c3
Update packages/kit/types/index.d.ts
Rich-Harris 44bd6f8
golf
0b52c89
Merge branch 'gh-5689' of github.com:sveltejs/kit into gh-5689
937675e
prettier
70b9825
WIP add navigation.complete promise
8a1f528
merge master
54b1e46
implement navigation.complete
6b1b4c8
merge master
fa16886
fix tests
02dc70f
Update packages/kit/types/ambient.d.ts
Rich-Harris f417004
a bit more detail in the docs
a6aacc0
lint
e96195b
merge master
eff8b4a
remove unwanted file
0e1b593
Merge branch 'master' into gh-5689
benmccann c68d625
fix lint
eltigerchino 7f868b8
Update packages/kit/src/exports/public.d.ts
Rich-Harris c7c8aa8
Apply suggestions from code review
Rich-Harris 5ba3015
bump dts-buddy
Rich-Harris 4ebf02b
merge master
Rich-Harris d0e3a74
fix
Rich-Harris fa6bc93
check
Rich-Harris File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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': minor | ||
--- | ||
|
||
feat: onNavigate lifecycle function |
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
5 changes: 0 additions & 5 deletions
5
packages/kit/test/apps/basics/src/routes/before-navigate/redirect/+page.js
This file was deleted.
Oops, something went wrong.
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
File renamed without changes.
File renamed without changes.
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
5 changes: 5 additions & 0 deletions
5
...es/kit/test/apps/basics/src/routes/navigation-lifecycle/before-navigate/redirect/+page.js
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 @@ | ||
import { redirect } from '@sveltejs/kit'; | ||
|
||
export function load() { | ||
throw redirect(307, '/navigation-lifecycle/before-navigate/prevent-navigation'); | ||
} |
21 changes: 21 additions & 0 deletions
21
packages/kit/test/apps/basics/src/routes/navigation-lifecycle/on-navigate/[x]/+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,21 @@ | ||
<script> | ||
import { onNavigate } from '$app/navigation'; | ||
|
||
/** @type {import('@sveltejs/kit').NavigationTarget} */ | ||
let from; | ||
|
||
/** @type {import('@sveltejs/kit').NavigationTarget} */ | ||
let to; | ||
|
||
/** @type {Omit<import('@sveltejs/kit').NavigationType, 'enter' | 'leave'>} */ | ||
let type; | ||
|
||
onNavigate((navigation) => { | ||
from = navigation.from; | ||
to = navigation.to; | ||
type = navigation.type; | ||
}); | ||
</script> | ||
|
||
<h1>{from?.url.pathname} -> {to?.url.pathname} ({type ?? '...'})</h1> | ||
<a href="/navigation-lifecycle/on-navigate/b">/b</a> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we consider what happens here if any of these callbacks reject? Or at least document the behavior? I'm not sure if it's the right behavior, but right now a rejected promise will prevent the navigation from completing.