From 73b9f47377ce7ad4dbfefdf03b267c5f3066f7c0 Mon Sep 17 00:00:00 2001 From: glacambre Date: Wed, 2 May 2018 19:34:13 +0200 Subject: [PATCH] excmds.ts: Fix scrollto(0/100,y) not working on some websites According to https://drafts.csswg.org/cssom-view/#dom-document-scrollingelement scrollingElement can be null. This happened on http://www.angelfire.com/super/badwebs/ . This caused `elem` to be null and resulted in an error when pressing G/gg. --- src/excmds.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/excmds.ts b/src/excmds.ts index d0ee3db1..dd2f9294 100644 --- a/src/excmds.ts +++ b/src/excmds.ts @@ -391,7 +391,7 @@ export function scrollpx(a: number, b: number) { //#content export function scrollto(a: number, b: number | "x" | "y" = "y") { a = Number(a) - let elem = window.document.scrollingElement + let elem = window.document.scrollingElement || window.document.body let percentage = a.clamp(0, 100) if (b === "y") { let top = elem.getClientRects()[0].top