From 18159a4d07d6f1953e658ffaeb6d7ffee15730ed Mon Sep 17 00:00:00 2001 From: John Factotum <50942278+johnfactotum@users.noreply.github.com> Date: Thu, 21 Mar 2024 20:22:31 +0800 Subject: [PATCH] Don't check document's existence when expanding `expand()` is only called after `render()`, which assumes that it exists --- paginator.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/paginator.js b/paginator.js index f5be2ec..9758c24 100644 --- a/paginator.js +++ b/paginator.js @@ -308,11 +308,12 @@ class View { } } expand() { + const { documentElement } = this.document if (this.#column) { const side = this.#vertical ? 'height' : 'width' const otherSide = this.#vertical ? 'width' : 'height' const contentRect = this.#contentRange.getBoundingClientRect() - const rootRect = this.document.documentElement.getBoundingClientRect() + const rootRect = documentElement.getBoundingClientRect() // offset caused by column break at the start of the page // which seem to be supported only by WebKit and only for horizontal writing const contentStart = this.#vertical ? 0 @@ -325,8 +326,7 @@ class View { this.#element.style[side] = `${expandedSize + this.#size * 2}px` this.#iframe.style[otherSide] = '100%' this.#element.style[otherSide] = '100%' - if (this.document) - this.document.documentElement.style[side] = `${this.#size}px` + documentElement.style[side] = `${this.#size}px` if (this.#overlayer) { this.#overlayer.element.style.margin = '0' this.#overlayer.element.style.left = this.#vertical ? '0' : `${this.#size}px` @@ -337,8 +337,7 @@ class View { } else { const side = this.#vertical ? 'width' : 'height' const otherSide = this.#vertical ? 'height' : 'width' - const doc = this.document - const contentSize = doc?.documentElement?.getBoundingClientRect()?.[side] + const contentSize = documentElement.getBoundingClientRect()[side] const expandedSize = contentSize const { margin } = this.#layout const padding = this.#vertical ? `0 ${margin}px` : `${margin}px 0`