Skip to content

Commit

Permalink
#681@trivial: Make sure to use optional chaining.
Browse files Browse the repository at this point in the history
  • Loading branch information
00defeat committed Dec 27, 2022
1 parent b5afc24 commit 78d4852
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/happy-dom/src/window/Window.ts
Expand Up @@ -489,7 +489,7 @@ export default class Window extends EventTarget implements IWindow {
* @returns number
*/
public get scrollX(): number {
return this.document.documentElement?.scrollLeft ?? 0;
return this.document?.documentElement?.scrollLeft ?? 0;
}

/**
Expand All @@ -507,7 +507,7 @@ export default class Window extends EventTarget implements IWindow {
* @returns number
*/
public get scrollY(): number {
return this.document.documentElement?.scrollTop ?? 0;
return this.document?.documentElement?.scrollTop ?? 0;
}

/**
Expand Down

0 comments on commit 78d4852

Please sign in to comment.