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 d4f7016 commit 45a90a7Copy full SHA for 45a90a7
src/js/02-on-this-page.js
@@ -29,7 +29,7 @@
29
var links = {}
30
var list = headings.reduce(function (accum, heading) {
31
var link = document.createElement('a')
32
- link.textContent = heading.textContent
+ link.textContent = [...heading.childNodes].reduce((acc, el) => { return acc + (el.nodeType === Node.TEXT_NODE ? el.textContent : '') }, '')
33
links[(link.href = '#' + heading.id)] = link
34
var listItem = document.createElement('li')
35
listItem.dataset.level = parseInt(heading.nodeName.slice(1)) - 1
0 commit comments