Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: use textContent to get header titles
The modern template currently uses `innerText` to get the text from h2
and h3 tags for the "In This Article" section of the affix. However,
this can cause links with empty text content to be generated for headers
which are not visible at the moment the navigation is generated, such as
those in a `<details>` element. Using `textContent` instead will still
properly retrieve the text from these headers.
  • Loading branch information
Preston Petrie committed Aug 21, 2025
commit f2ce8a96d97df0b4115baa04b3ccfd957e4f3b5c
4 changes: 2 additions & 2 deletions templates/modern/src/nav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ function inThisArticle(): TemplateResult {
return html`
<h5 class="border-bottom">${loc('inThisArticle')}</h5>
<ul>${headings.map(h => h.tagName === 'H2'
? html`<li><a class="link-body-emphasis" href="#${h.id}">${breakWordLit(h.innerText)}</a></li>`
: html`<li><a class="link-secondary" href="#${h.id}">${breakWordLit(h.innerText)}</a></li>`
? html`<li><a class="link-body-emphasis" href="#${h.id}">${breakWordLit(h.textContent)}</a></li>`
: html`<li><a class="link-secondary" href="#${h.id}">${breakWordLit(h.textContent)}</a></li>`
)}</ul>`
}
}
Expand Down
Loading