Skip to content

Commit

Permalink
refactor: move onBeforePageLoad inside loadPage
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd committed Jul 2, 2023
1 parent 665f3b0 commit a3df617
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/client/app/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ export function createRouter(
history.replaceState({ scrollPosition: window.scrollY }, document.title)
history.pushState(null, '', href)
}
if ((await router.onBeforePageLoad?.(href)) === false) return
await loadPage(href)
await router.onAfterRouteChanged?.(href)
}

let latestPendingPath: string | null = null

async function loadPage(href: string, scrollPosition = 0, isRetry = false) {
if ((await router.onBeforePageLoad?.(href)) === false) return
const targetLoc = new URL(href, fakeHost)
const pendingPath = (latestPendingPath = targetLoc.pathname)
try {
Expand Down

0 comments on commit a3df617

Please sign in to comment.