fix: anchor link need decode

(cherry picked from commit 8620d43c77cf8b8ae15907f223b07848a926c9fb)
This commit is contained in:
Trock 2022-11-06 20:08:12 +08:00
parent 196116f20d
commit 3685845eec

View File

@ -21,8 +21,8 @@ function setupSmoothAnchors() {
aElement.addEventListener("click", clickEvent => {
clickEvent.preventDefault();
const targetId = aElement.getAttribute("href").substring(1),
target = document.getElementById(targetId) as HTMLElement,
const targetId = decodeURI(aElement.getAttribute("href").substring(1)),
target = document.getElementById(targetId) as HTMLElement,
offset = target.getBoundingClientRect().top - document.documentElement.getBoundingClientRect().top;
window.history.pushState({}, "", aElement.getAttribute("href"));