From 8cad7d61eb46c261b09e2c064d5792b7198057ca Mon Sep 17 00:00:00 2001 From: tophf Date: Tue, 17 Apr 2018 22:34:18 +0300 Subject: [PATCH] scrollElementIntoView: skip if orphaned --- js/dom.js | 1 + 1 file changed, 1 insertion(+) 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;