diff --git a/src/lib/SkHistoryApi.svelte.test.ts b/src/lib/SkHistoryApi.svelte.test.ts index 2575e44..0447317 100644 --- a/src/lib/SkHistoryApi.svelte.test.ts +++ b/src/lib/SkHistoryApi.svelte.test.ts @@ -111,7 +111,7 @@ describe("SkHistoryApi", () => { test("Should call goto with the correct arguments for pushState.", () => { const state = { foo: "bar" }; historyApi.pushState(state, '', 'http://localhost/new-page'); - expect(goto).toHaveBeenCalledWith('http://localhost/new-page', { state }); + expect(goto).toHaveBeenCalledWith('http://localhost/new-page', { state, noScroll: true }); }); test.each([ @@ -125,7 +125,7 @@ describe("SkHistoryApi", () => { test("Should call goto with the correct arguments for replaceState.", () => { const state = { foo: "bar" }; historyApi.replaceState(state, '', 'http://localhost/new-page'); - expect(goto).toHaveBeenCalledWith('http://localhost/new-page', { state, replaceState: true }); + expect(goto).toHaveBeenCalledWith('http://localhost/new-page', { state, replaceState: true, noScroll: true }); }); test.each([ diff --git a/src/lib/SkHistoryApi.ts b/src/lib/SkHistoryApi.ts index cb49a1e..e7c8ec9 100644 --- a/src/lib/SkHistoryApi.ts +++ b/src/lib/SkHistoryApi.ts @@ -59,11 +59,11 @@ export class SkHistoryApi implements HistoryApi { pushState(data: any, unused: string, url?: string | URL | null): void { assertValidUrl(url); - goto(url, { state: data }); + goto(url, { state: data, noScroll: true }); } replaceState(data: any, unused: string, url?: string | URL | null): void { assertValidUrl(url); - goto(url, { state: data, replaceState: true }); + goto(url, { state: data, replaceState: true, noScroll: true }); } }