Skip to content

Commit 4bc0fdb

Browse files
committed
Use documentElement for scroll to top
1 parent 61bf99d commit 4bc0fdb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ function reset() {
1919
function getElAndScroll() {
2020
let element = null;
2121
if (hashFragment === '#') {
22-
element = document.body;
22+
element = document.documentElement;
2323
} else {
2424
// check for element with matching id before assume '#top' is the top of the document
2525
// see https://html.spec.whatwg.org/multipage/browsing-the-web.html#target-element
2626
const id = hashFragment.replace('#', '');
2727
element = document.getElementById(id);
2828
if (element === null && hashFragment === '#top') {
29-
element = document.body;
29+
element = document.documentElement;
3030
}
3131
}
3232

0 commit comments

Comments
 (0)