help: Fix exception with invalid fragment causing bogus extra scrollbars.

Apparently, our scrollbar logic crashed with an invalid URL fragment
(hash), which resulted in initialization not completing and thus the
logic failing.

In my view the root issue here is that we're not doing a good job of
catching JavaScript exceptions in portico pages.

Fixes #15706.
This commit is contained in:
Tim Abbott 2020-07-14 12:19:52 -07:00
parent f364414cb9
commit 42d601e214
1 changed files with 1 additions and 1 deletions

View File

@ -56,7 +56,7 @@ function render_code_sections() {
function scrollToHash(simplebar) {
const hash = window.location.hash;
const scrollbar = simplebar.getScrollElement();
if (hash !== '') {
if (hash !== '' && $(hash).length > 0) {
const position = $(hash).position().top - $(scrollbar.firstChild).position().top;
scrollbar.scrollTop = position;
} else {