#2371 Checks footnote target before overriding browser default behavior

This commit is contained in:
Andrew Brehaut 2021-03-11 08:16:51 +13:00 committed by Maurice Parker
parent 3132a2c779
commit bffd341992
1 changed files with 8 additions and 3 deletions

View File

@ -140,12 +140,17 @@
if (targetId) break;
}
if (targetId === undefined) return;
// Only override the default behaviour when we know we can find the
// target element
const targetElement = document.querySelector(`[id='${targetId}']`);
if (targetElement === null) return;
ev.preventDefault();
installContainer(ev.target);
const content = document.querySelector(`[id='${targetId}']`).innerHTML;
void new Footnote(content, ev.target);
void new Footnote(targetElement.innerHTML, ev.target);
});
// Handle clicks on the footnote reverse link