Skip to content
This repository was archived by the owner on May 8, 2018. It is now read-only.

Commit ad08826

Browse files
committed
preventing errors in case we're highlighting body
1 parent 1c12917 commit ad08826

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

intro.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@
611611

612612
var parentElm = targetElement.element.parentNode;
613613
while (parentElm != null) {
614-
if (parentElm.tagName.toLowerCase() === 'body') break;
614+
if (parentElm.tagName.toLowerCase() === 'body' || parentElm.tagName.toLowerCase() === 'html') break;
615615

616616
var zIndex = _getPropValue(parentElm, 'z-index');
617617
if (/[0-9]+/.test(zIndex)) {
@@ -620,7 +620,10 @@
620620
parentElm = parentElm.parentNode;
621621
}
622622

623-
if (!_elementInViewport(targetElement.element)) {
623+
if (targetElement.element.tagName.toLowerCase() === 'body') {
624+
window.scrollTo(0, 0) // scroll to top when highlighting the whole page
625+
626+
} else if (!_elementInViewport(targetElement.element)) {
624627
var rect = targetElement.element.getBoundingClientRect(),
625628
winHeight=_getWinSize().height,
626629
top = rect.bottom - (rect.bottom - rect.top),

0 commit comments

Comments
 (0)