Skip to content

Commit 16516c5

Browse files
committed
also handle document.getElementsByName
1 parent be3794c commit 16516c5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

web_src/js/markup/anchors.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ function scrollToAnchor(encodedId) {
1313

1414
// check for matching user-generated `a[name]`
1515
if (!el) {
16-
const nameAnchors = document.getElementsByName(prefixedId);
17-
if (nameAnchors.length) {
18-
el = nameAnchors[0];
16+
const nameAnchor = document.querySelector(`[name="${CSS.escape(prefixedId)}"]`);
17+
if (nameAnchor) {
18+
el = nameAnchor;
1919
}
2020
}
2121

0 commit comments

Comments
 (0)