Skip to content

Commit

Permalink
rename goto(href) to goto(url) (#5286)
Browse files Browse the repository at this point in the history
* rename goto(href) to goto(url)

* update types
  • Loading branch information
Rich-Harris authored Jun 27, 2022
1 parent 5db49d5 commit f81e4a8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
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 @@ -122,16 +122,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

0 comments on commit f81e4a8

Please sign in to comment.