mirror of
https://github.com/vale981/tridactyl
synced 2025-03-06 01:51:40 -05:00
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.
This commit is contained in:
parent
c868f61973
commit
73b9f47377
1 changed files with 1 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue