diff --git a/js/dom.js b/js/dom.js index 15e935b7..efdcbb24 100644 --- a/js/dom.js +++ b/js/dom.js @@ -96,6 +96,7 @@ function onDOMready() { function scrollElementIntoView(element, {invalidMarginRatio = 0} = {}) { // align to the top/bottom of the visible area if wasn't visible + if (!element.parentNode) return; const {top, height} = element.getBoundingClientRect(); const {top: parentTop, bottom: parentBottom} = element.parentNode.getBoundingClientRect(); const windowHeight = window.innerHeight;