Skip to content

Commit

Permalink
Try to fix #196
Browse files Browse the repository at this point in the history
  • Loading branch information
papandreou committed Nov 20, 2021
1 parent c84d347 commit 3051c35
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,21 +529,21 @@ async function hyperlink(
!asset.isRedirect && (asset.crossedOrigins || !recursive);
}

// Remember the set of ids in the document before unloading so incoming fragments can be checked:
asset.ids = new Set();
for (const element of Array.from(
asset.parseTree.querySelectorAll('[id]')
)) {
asset.ids.add(element.getAttribute('id'));
}

// Remember the set of ids in the document before unloading so incoming fragments can be checked
// Remember the set of names and ids in the document before unloading so incoming fragments can be checked:
// See https://github.com/Munter/hyperlink/issues/160
asset.ids = new Set();
asset.names = new Set();
for (const element of Array.from(
asset.parseTree.querySelectorAll('[name]')
)) {
asset.names.add(element.getAttribute('name'));
if (asset.isLoaded) {
for (const element of Array.from(
asset.parseTree.querySelectorAll('[id]')
)) {
asset.ids.add(element.getAttribute('id'));
}
for (const element of Array.from(
asset.parseTree.querySelectorAll('[name]')
)) {
asset.names.add(element.getAttribute('name'));
}
}
}

Expand Down

0 comments on commit 3051c35

Please sign in to comment.