mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-26 13:29:12 -05:00
Backport #29679 by @silverwind Followup https://github.com/go-gitea/gitea/pull/29305. As per discussion in https://github.com/go-gitea/gitea/pull/29666#discussion_r1517506422, 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 <me@silverwind.io> (cherry picked from commit 25b0c99a41e9024d439deaa55be7ba87f6cd557f)
This commit is contained in:
parent
03caefbb02
commit
ac05e205ba
1 changed files with 1 additions and 1 deletions
|
@ -39,7 +39,7 @@ export function initMarkupAnchors() {
|
||||||
if (!href.startsWith('#user-content-')) continue;
|
if (!href.startsWith('#user-content-')) continue;
|
||||||
const originalId = href.replace(/^#user-content-/, '');
|
const originalId = href.replace(/^#user-content-/, '');
|
||||||
a.setAttribute('href', `#${encodeURIComponent(originalId)}`);
|
a.setAttribute('href', `#${encodeURIComponent(originalId)}`);
|
||||||
if (document.getElementsByName(originalId).length !== 1) {
|
if (a.closest('.markup').querySelectorAll(`a[name="${originalId}"]`).length !== 1) {
|
||||||
a.addEventListener('click', (e) => {
|
a.addEventListener('click', (e) => {
|
||||||
scrollToAnchor(e.currentTarget.getAttribute('href'), false);
|
scrollToAnchor(e.currentTarget.getAttribute('href'), false);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue