Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gentle-signs-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': major
---

breaking: the `delta` property now only exists for `popstate` navigation events
30 changes: 1 addition & 29 deletions packages/kit/src/exports/public.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ export interface KitConfig {
* - `preload-mjs` - uses `<link rel="preload">` but with the `.mjs` extension which prevents double-parsing in Chromium. Some static webservers will fail to serve .mjs files with a `Content-Type: application/javascript` header, which will cause your application to break. If that doesn't apply to you, this is the option that will deliver the best performance for the largest number of users, until `modulepreload` is more widely supported.
* @default "modulepreload"
* @since 1.8.4
* @deprecated removed in 3.0.0
* @deprecated removed in 3.0
*/
preloadStrategy?: 'modulepreload' | 'preload-js' | 'preload-mjs';
/**
Expand Down Expand Up @@ -1265,13 +1265,6 @@ export interface NavigationGoto extends NavigationBase {
* - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
*/
type: 'goto';

// TODO 3.0 remove this property, so that it only exists when type is 'popstate'
// (would possibly be a breaking change to do it prior to that)
/**
* In case of a history back/forward navigation, the number of steps to go back/forward
*/
delta?: undefined;
}

export interface NavigationLeave extends NavigationBase {
Expand All @@ -1280,13 +1273,6 @@ export interface NavigationLeave extends NavigationBase {
* - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring
*/
type: 'leave';

// TODO 3.0 remove this property, so that it only exists when type is 'popstate'
// (would possibly be a breaking change to do it prior to that)
/**
* In case of a history back/forward navigation, the number of steps to go back/forward
*/
delta?: undefined;
}

export interface NavigationFormSubmit extends NavigationBase {
Expand All @@ -1300,13 +1286,6 @@ export interface NavigationFormSubmit extends NavigationBase {
* The `SubmitEvent` that caused the navigation
*/
event: SubmitEvent;

// TODO 3.0 remove this property, so that it only exists when type is 'popstate'
// (would possibly be a breaking change to do it prior to that)
/**
* In case of a history back/forward navigation, the number of steps to go back/forward
*/
delta?: undefined;
}

export interface NavigationPopState extends NavigationBase {
Expand Down Expand Up @@ -1338,13 +1317,6 @@ export interface NavigationLink extends NavigationBase {
* The `PointerEvent` that caused the navigation
*/
event: PointerEvent;

// TODO 3.0 remove this property, so that it only exists when type is 'popstate'
// (would possibly be a breaking change to do it prior to that)
/**
* In case of a history back/forward navigation, the number of steps to go back/forward
*/
delta?: undefined;
}

export type Navigation =
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/runtime/app/state/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const navigating = {
return _navigating.current ? _navigating.current.willUnload : null;
},
get delta() {
return _navigating.current ? _navigating.current.delta : null;
return _navigating.current?.type === 'popstate' ? _navigating.current.delta : null;
},
get complete() {
return _navigating.current ? _navigating.current.complete : null;
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/runtime/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1476,7 +1476,7 @@ function _before_navigate({ url, type, intent, delta, event, scroll }) {

const nav = create_navigation(current, intent, url, type, scroll ?? null);

if (delta !== undefined) {
if (nav.navigation.type === 'popstate' && delta !== undefined) {
nav.navigation.delta = delta;
}

Expand Down
30 changes: 1 addition & 29 deletions packages/kit/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ declare module '@sveltejs/kit' {
* - `preload-mjs` - uses `<link rel="preload">` but with the `.mjs` extension which prevents double-parsing in Chromium. Some static webservers will fail to serve .mjs files with a `Content-Type: application/javascript` header, which will cause your application to break. If that doesn't apply to you, this is the option that will deliver the best performance for the largest number of users, until `modulepreload` is more widely supported.
* @default "modulepreload"
* @since 1.8.4
* @deprecated removed in 3.0.0
* @deprecated removed in 3.0
*/
preloadStrategy?: 'modulepreload' | 'preload-js' | 'preload-mjs';
/**
Expand Down Expand Up @@ -1239,13 +1239,6 @@ declare module '@sveltejs/kit' {
* - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
*/
type: 'goto';

// TODO 3.0 remove this property, so that it only exists when type is 'popstate'
// (would possibly be a breaking change to do it prior to that)
/**
* In case of a history back/forward navigation, the number of steps to go back/forward
*/
delta?: undefined;
}

export interface NavigationLeave extends NavigationBase {
Expand All @@ -1254,13 +1247,6 @@ declare module '@sveltejs/kit' {
* - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring
*/
type: 'leave';

// TODO 3.0 remove this property, so that it only exists when type is 'popstate'
// (would possibly be a breaking change to do it prior to that)
/**
* In case of a history back/forward navigation, the number of steps to go back/forward
*/
delta?: undefined;
}

export interface NavigationFormSubmit extends NavigationBase {
Expand All @@ -1274,13 +1260,6 @@ declare module '@sveltejs/kit' {
* The `SubmitEvent` that caused the navigation
*/
event: SubmitEvent;

// TODO 3.0 remove this property, so that it only exists when type is 'popstate'
// (would possibly be a breaking change to do it prior to that)
/**
* In case of a history back/forward navigation, the number of steps to go back/forward
*/
delta?: undefined;
}

export interface NavigationPopState extends NavigationBase {
Expand Down Expand Up @@ -1312,13 +1291,6 @@ declare module '@sveltejs/kit' {
* The `PointerEvent` that caused the navigation
*/
event: PointerEvent;

// TODO 3.0 remove this property, so that it only exists when type is 'popstate'
// (would possibly be a breaking change to do it prior to that)
/**
* In case of a history back/forward navigation, the number of steps to go back/forward
*/
delta?: undefined;
}

export type Navigation =
Expand Down
Loading