diff --git a/src/patch/window/scroll-by.ts b/src/patch/window/scroll-by.ts index 028fb09..2baed2d 100644 --- a/src/patch/window/scroll-by.ts +++ b/src/patch/window/scroll-by.ts @@ -4,7 +4,7 @@ import {handleScrollMethod} from "../shared"; * Patches the 'scrollBy' method on the Window prototype */ export function patchWindowScrollBy(): void { - window.scrollBy = function(this: Window, optionsOrX?: number | ScrollToOptions, y?: number): void { - handleScrollMethod(this, "scrollBy", optionsOrX, y); + window.scrollBy = function(this: Window | undefined, optionsOrX?: number | ScrollToOptions, y?: number): void { + handleScrollMethod(this ?? window, "scrollBy", optionsOrX, y); }; } diff --git a/src/patch/window/scroll-to.ts b/src/patch/window/scroll-to.ts index e7bc3e8..3090071 100644 --- a/src/patch/window/scroll-to.ts +++ b/src/patch/window/scroll-to.ts @@ -4,7 +4,7 @@ import {handleScrollMethod} from "../shared"; * Patches the 'scrollTo' method on the Window prototype */ export function patchWindowScrollTo(): void { - window.scrollTo = function(this: Window, optionsOrX?: number | ScrollToOptions, y?: number): void { - handleScrollMethod(this, "scrollTo", optionsOrX, y); + window.scrollTo = function(this: Window | undefined, optionsOrX?: number | ScrollToOptions, y?: number): void { + handleScrollMethod(this ?? window, "scrollTo", optionsOrX, y); }; } diff --git a/src/patch/window/scroll.ts b/src/patch/window/scroll.ts index e45f5a5..0ac859e 100644 --- a/src/patch/window/scroll.ts +++ b/src/patch/window/scroll.ts @@ -4,7 +4,7 @@ import {handleScrollMethod} from "../shared"; * Patches the 'scroll' method on the Window prototype */ export function patchWindowScroll(): void { - window.scroll = function(this: Window, optionsOrX?: number | ScrollToOptions, y?: number): void { - handleScrollMethod(this, "scroll", optionsOrX, y); + window.scroll = function(this: Window | undefined, optionsOrX?: number | ScrollToOptions, y?: number): void { + handleScrollMethod(this ?? window, "scroll", optionsOrX, y); }; }