From 8f7eeb7de69e28a65ebd03e85c81493047c8fe78 Mon Sep 17 00:00:00 2001 From: "Gleb A." <94681073+gleb-kun@users.noreply.github.com> Date: Sun, 2 Nov 2025 04:57:02 +0800 Subject: [PATCH] fix: Uncaught TypeError: link is null in buildIdToNavigationElementMap (#1133) fix: Uncaught TypeError: link is null in buildIdToNavigationElementMap (#1132) --- assets/ts/scrollspy.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/assets/ts/scrollspy.ts b/assets/ts/scrollspy.ts index 8a14085..22c0217 100644 --- a/assets/ts/scrollspy.ts +++ b/assets/ts/scrollspy.ts @@ -32,9 +32,11 @@ function buildIdToNavigationElementMap(navigation: NodeListOf): 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; + } } });