We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 84f1cd1 commit c849fffCopy full SHA for c849fff
js/table-of-contents.ts
@@ -92,8 +92,19 @@ const initialize = (): void => {
92
nav.setAttribute('role', 'navigation');
93
nav.setAttribute('aria-label', 'Table of Contents');
94
95
- for (const x of Array.from(document.getElementById('article')?.querySelectorAll('a.header') ?? [])) {
+ const article = document.getElementById('article');
96
+ if (!article) {
97
+ console.error('Article element not found');
98
+ return;
99
+ }
100
+
101
+ const headers = article.querySelectorAll('a.header');
102
+ for (const x of Array.from(headers)) {
103
const el = x as HTMLAnchorElement;
104
+ if (!el.parentElement) {
105
+ console.error('Header element has no parent');
106
+ continue;
107
108
109
observer.observe(el);
110
0 commit comments