Skip to content
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

rename goto(href) to goto(url) #5286

Merged
merged 2 commits into from
Jun 27, 2022
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/short-lamps-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

rename `goto(href)` to `goto(url)`
8 changes: 5 additions & 3 deletions packages/kit/src/runtime/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,18 @@ export function create_client({ target, session, base, trailing_slash }) {
let token;

/**
* @param {string | URL} href
* @param {string | URL} url
* @param {{ noscroll?: boolean; replaceState?: boolean; keepfocus?: boolean; state?: any }} opts
* @param {string[]} redirect_chain
*/
async function goto(
href,
url,
{ noscroll = false, replaceState = false, keepfocus = false, state = {} },
redirect_chain
) {
const url = new URL(href, get_base_uri(document));
if (typeof url === 'string') {
url = new URL(url, get_base_uri(document));
}

if (router_enabled) {
return navigate({
Expand Down
6 changes: 3 additions & 3 deletions packages/kit/types/ambient.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,16 @@ declare module '$app/navigation' {
*/
export function disableScrollHandling(): void;
/**
* Returns a Promise that resolves when SvelteKit navigates (or fails to navigate, in which case the promise rejects) to the specified `href`.
* Returns a Promise that resolves when SvelteKit navigates (or fails to navigate, in which case the promise rejects) to the specified `url`.
*
* @param href Where to navigate to
* @param url Where to navigate to
* @param opts.replaceState If `true`, will replace the current `history` entry rather than creating a new one with `pushState`
* @param opts.noscroll If `true`, the browser will maintain its scroll position rather than scrolling to the top of the page after navigation
* @param opts.keepfocus If `true`, the currently focused element will retain focus after navigation. Otherwise, focus will be reset to the body
* @param opts.state The state of the new/updated history entry
*/
export function goto(
href: string,
url: string | URL,
opts?: { replaceState?: boolean; noscroll?: boolean; keepfocus?: boolean; state?: any }
): Promise<void>;
/**
Expand Down