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

This commit is contained in:
gleb-kun 2025-03-08 00:46:49 +03:00
parent 9e6b7b22a9
commit 899c0a5bb9

View File

@ -32,9 +32,11 @@ function buildIdToNavigationElementMap(navigation: NodeListOf<Element>): IdToEle
const sectionLinkRef: IdToElementMap = {};
navigation.forEach((navigationElement: HTMLElement) => {
const link = navigationElement.querySelector("a");
const href = link.getAttribute("href");
if (href.startsWith("#")) {
sectionLinkRef[href.slice(1)] = navigationElement;
if (link) {
const href = link.getAttribute("href");
if (href.startsWith("#")) {
sectionLinkRef[href.slice(1)] = navigationElement;
}
}
});