Skip to content

Commit 2dbdc12

Browse files
authored
Update nav-for-headings.html
I prompted in the existing conversation: > Make sure to populate existingIds with the IDs on the page to start
1 parent 43100d1 commit 2dbdc12

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

nav-for-headings.html

+3-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@
109109
const url = document.getElementById('urlInput').value
110110
const parser = new DOMParser()
111111
const doc = parser.parseFromString(html, 'text/html')
112-
const existingIds = new Set()
112+
// Collect all existing IDs on the page first
113+
const existingIds = new Set([...doc.querySelectorAll('[id]')].map(el => el.id))
113114
const headers = doc.querySelectorAll('h1, h2, h3, h4, h5, h6')
114115
const headerLinks = []
115116

@@ -125,4 +126,4 @@
125126
}
126127
</script>
127128
</body>
128-
</html>
129+
</html>

0 commit comments

Comments
 (0)