From 7142de24cc211d52a4db0bb88c7ed10748ab397d Mon Sep 17 00:00:00 2001 From: lonzzi Date: Sat, 11 Jun 2022 06:39:16 +0800 Subject: fix(article): TOC link not working when the heading starts with digits (#603) --- assets/ts/smoothAnchors.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/ts/smoothAnchors.ts b/assets/ts/smoothAnchors.ts index 0718bf5..379eb39 100644 --- a/assets/ts/smoothAnchors.ts +++ b/assets/ts/smoothAnchors.ts @@ -23,7 +23,7 @@ function setupSmoothAnchors() { let targetId = aElement.getAttribute("href").substring(1); // The replace done on ':' is here for footnotes, as this character would otherwise interfere when used as a CSS selector. - let target = document.querySelector(`#${targetId.replace(":", "\\:")}`) as HTMLElement; + let target = document.getElementById(targetId.replace(":", "\\:")) as HTMLElement; window.history.pushState({}, "", aElement.getAttribute("href")); scrollTo({ top: target.offsetTop, behavior: "smooth" }); -- cgit v1.2.3