From 1f2f1ff43dbb3c1598810fe04608678426e4fed5 Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 15 Mar 2023 18:10:06 +0800 Subject: [PATCH] fix: decode when query selecting current hash close #2089 --- src/client/app/index.ts | 2 +- src/client/theme-default/components/VPSkipLink.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/app/index.ts b/src/client/app/index.ts index b3ec5e90..795674a2 100644 --- a/src/client/app/index.ts +++ b/src/client/app/index.ts @@ -152,7 +152,7 @@ if (inBrowser) { // scroll to hash on new tab during dev if (import.meta.env.DEV && location.hash) { - const target = document.querySelector(location.hash) + const target = document.querySelector(decodeURIComponent(location.hash)) if (target) { scrollTo(target, location.hash) } diff --git a/src/client/theme-default/components/VPSkipLink.vue b/src/client/theme-default/components/VPSkipLink.vue index 492e0148..69f17a44 100644 --- a/src/client/theme-default/components/VPSkipLink.vue +++ b/src/client/theme-default/components/VPSkipLink.vue @@ -9,7 +9,7 @@ watch(() => route.path, () => backToTop.value.focus()) function focusOnTargetAnchor({ target }: Event) { const el = document.querySelector( - (target as HTMLAnchorElement).hash + decodeURIComponent((target as HTMLAnchorElement).hash) ) if (el) {