handle query changes

pull/4511/head
Divyansh Singh 8 months ago
parent 4246ec4b5a
commit b4369aa736

@ -78,15 +78,13 @@ export function createRouter(
if (inBrowser) {
loc = normalizeHref(location.href)
const { pathname, search, hash } = new URL(href, fakeHost)
const { pathname, hash } = new URL(href, fakeHost)
const currentLoc = new URL(loc, fakeHost)
if (
pathname === currentLoc.pathname &&
search === currentLoc.search &&
hash !== currentLoc.hash
) {
if (pathname === currentLoc.pathname && href !== loc) {
history.pushState({}, '', href)
if (hash !== currentLoc.hash) {
window.dispatchEvent(
new HashChangeEvent('hashchange', {
oldURL: currentLoc.href,
@ -95,6 +93,7 @@ export function createRouter(
)
hash ? scrollTo(hash) : window.scrollTo(0, 0)
}
return
}

Loading…
Cancel
Save