From a3df6171abffe3637608a20755d427c4458a173e Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Sun, 2 Jul 2023 14:33:27 +0530 Subject: [PATCH] refactor: move onBeforePageLoad inside loadPage --- src/client/app/router.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/app/router.ts b/src/client/app/router.ts index 084d4e78..cbfc9e14 100644 --- a/src/client/app/router.ts +++ b/src/client/app/router.ts @@ -79,7 +79,6 @@ 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) } @@ -87,6 +86,7 @@ export function createRouter( 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 {