Skip to content

Commit 25b0c99

Browse files
GiteaBotsilverwind
andauthored
Use more specific selector for name links (#29679) (#29681)
Backport #29679 by @silverwind Followup #29305. As per discussion in #29666 (comment), make this selector only search in the current `.markup` document, as there can be multiples displayed at the same time. @DanielMatiasCarvalho maybe you can review. Co-authored-by: silverwind <[email protected]>
1 parent bfc7c8a commit 25b0c99

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

web_src/js/markup/anchors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function initMarkupAnchors() {
3939
if (!href.startsWith('#user-content-')) continue;
4040
const originalId = href.replace(/^#user-content-/, '');
4141
a.setAttribute('href', `#${encodeURIComponent(originalId)}`);
42-
if (document.getElementsByName(originalId).length !== 1) {
42+
if (a.closest('.markup').querySelectorAll(`a[name="${originalId}"]`).length !== 1) {
4343
a.addEventListener('click', (e) => {
4444
scrollToAnchor(e.currentTarget.getAttribute('href'), false);
4545
});

0 commit comments

Comments
 (0)