Merge pull request #2867 from brehaut/main

#2371 Checks footnote target before overriding browser default behavior
This commit is contained in:
Maurice Parker 2021-03-10 18:39:52 -06:00 committed by GitHub
commit 1b6ec8cfd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

@ -141,11 +141,16 @@
}
if (targetId === undefined) return;
// Only override the default behaviour when we know we can find the
// target element
const targetElement = document.getElementById(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