fix(article): TOC link not working when the heading starts with digits (#603)
This commit is contained in:
parent
9aa6b4925b
commit
7142de24cc
@ -23,7 +23,7 @@ function setupSmoothAnchors() {
|
|||||||
|
|
||||||
let targetId = aElement.getAttribute("href").substring(1);
|
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.
|
// 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"));
|
window.history.pushState({}, "", aElement.getAttribute("href"));
|
||||||
scrollTo({ top: target.offsetTop, behavior: "smooth" });
|
scrollTo({ top: target.offsetTop, behavior: "smooth" });
|
||||||
|
Loading…
Reference in New Issue
Block a user