Skip to content

Commit bc36e9d

Browse files
committed
refactor(router-core): update location building for navigate
Signed-off-by: leesb971204 <[email protected]>
1 parent 9251031 commit bc36e9d

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

packages/router-core/src/router.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,8 +1917,14 @@ export class RouterCore<
19171917
} catch {}
19181918
}
19191919

1920+
const nextLocation = this.buildLocation({
1921+
to,
1922+
...rest,
1923+
_includeValidateSearch: true,
1924+
_isNavigate: true,
1925+
} as any)
1926+
19201927
if (!reloadDocument) {
1921-
const nextLocation = this.buildLocation({ to, href, ...rest } as any)
19221928
const currentOrigin = new URL(this.latestLocation.url).origin
19231929
const nextOrigin = new URL(nextLocation.url).origin
19241930

@@ -1930,8 +1936,7 @@ export class RouterCore<
19301936

19311937
if (reloadDocument) {
19321938
if (!href) {
1933-
const location = this.buildLocation({ to, ...rest } as any)
1934-
href = location.url
1939+
href = nextLocation.url
19351940
}
19361941
if (rest.replace) {
19371942
window.location.replace(href)
@@ -1941,11 +1946,13 @@ export class RouterCore<
19411946
return Promise.resolve()
19421947
}
19431948

1944-
return this.buildAndCommitLocation({
1945-
...rest,
1946-
href,
1947-
to: to as string,
1948-
_isNavigate: true,
1949+
return this.commitLocation({
1950+
...nextLocation,
1951+
replace: rest.replace,
1952+
resetScroll: rest.resetScroll,
1953+
hashScrollIntoView: rest.hashScrollIntoView,
1954+
viewTransition: rest.viewTransition,
1955+
ignoreBlocker: rest.ignoreBlocker,
19491956
})
19501957
}
19511958

0 commit comments

Comments
 (0)