Skip to content

Commit

Permalink
web: fix scrollToHash
Browse files Browse the repository at this point in the history
  • Loading branch information
ncfavier authored and plt-amy committed Dec 16, 2023
1 parent 65092be commit 5baab64
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions support/web/js/equations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ function scrollToHash() {
const id = window.location.hash.slice(1);
// #id doesn't work with numerical IDs
const elem = document.querySelector(`[id="${id}"]`);
if (!(elem instanceof HTMLInputElement)) return;
if (!(elem instanceof HTMLElement)) return;
// If the element is in a commented-out block or a <details> tag, unhide it
// and scroll to it.
const commentedOut = elem.closest('.commented-out') as HTMLInputElement | null;
const commentedOut = elem.closest('.commented-out') as HTMLElement | null;
if (commentedOut)
commentedOut.style.display = 'revert';
const details = elem.closest('details') as HTMLInputElement | null;
const details = elem.closest('details') as HTMLElement | null;
if (details)
details.setAttribute("open", "");
if (commentedOut || details)
Expand Down

0 comments on commit 5baab64

Please sign in to comment.