Skip to content

Commit a3df617

Browse files
committed
refactor: move onBeforePageLoad inside loadPage
1 parent 665f3b0 commit a3df617

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/client/app/router.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ export function createRouter(
7979
history.replaceState({ scrollPosition: window.scrollY }, document.title)
8080
history.pushState(null, '', href)
8181
}
82-
if ((await router.onBeforePageLoad?.(href)) === false) return
8382
await loadPage(href)
8483
await router.onAfterRouteChanged?.(href)
8584
}
8685

8786
let latestPendingPath: string | null = null
8887

8988
async function loadPage(href: string, scrollPosition = 0, isRetry = false) {
89+
if ((await router.onBeforePageLoad?.(href)) === false) return
9090
const targetLoc = new URL(href, fakeHost)
9191
const pendingPath = (latestPendingPath = targetLoc.pathname)
9292
try {

0 commit comments

Comments
 (0)