fix: Uncaught TypeError: link is null in buildIdToNavigationElementMap (#1133)

fix: Uncaught TypeError: link is null in buildIdToNavigationElementMap (#1132)
This commit is contained in:
Gleb A.
2025-11-01 21:57:02 +01:00
committed by GitHub
parent dd3bb1ea13
commit 8f7eeb7de6
+5 -3
View File
@@ -32,9 +32,11 @@ function buildIdToNavigationElementMap(navigation: NodeListOf<Element>): IdToEle
const sectionLinkRef: IdToElementMap = {}; const sectionLinkRef: IdToElementMap = {};
navigation.forEach((navigationElement: HTMLElement) => { navigation.forEach((navigationElement: HTMLElement) => {
const link = navigationElement.querySelector("a"); const link = navigationElement.querySelector("a");
const href = link.getAttribute("href"); if (link) {
if (href.startsWith("#")) { const href = link.getAttribute("href");
sectionLinkRef[href.slice(1)] = navigationElement; if (href.startsWith("#")) {
sectionLinkRef[href.slice(1)] = navigationElement;
}
} }
}); });