fix(ui): prevent console error when leaving reader (#956)

This commit is contained in:
James Ward
2026-04-28 09:40:24 -04:00
committed by GitHub
parent 4001b042b3
commit f359e49a6b
+9 -7
View File
@@ -360,7 +360,9 @@ class View {
}
}
expand() {
const { documentElement } = this.document
const documentElement = this.document?.documentElement
// If the document element isn't set we probably have disconnected the paginator
if (!documentElement) return;
if (this.#column) {
const side = this.#vertical ? 'height' : 'width'
const otherSide = this.#vertical ? 'width' : 'height'
@@ -415,8 +417,8 @@ class View {
get overlayer() {
return this.#overlayer
}
destroy() {
if (this.document) this.#observer.unobserve(this.document.body)
disconnectedCallback() {
this.#observer.disconnect()
}
}
@@ -665,7 +667,7 @@ export class Paginator extends HTMLElement {
}
#createView() {
if (this.#view) {
this.#view.destroy()
this.#view.disconnectedCallback()
this.#container.removeChild(this.#view.element)
}
this.#view = new View({
@@ -1118,9 +1120,9 @@ export class Paginator extends HTMLElement {
focusView() {
this.#view.document.defaultView.focus()
}
destroy() {
this.#observer.unobserve(this)
this.#view.destroy()
disconnectedCallback() {
this.#observer.disconnect();
this.#view?.disconnectedCallback()
this.#view = null
this.sections[this.#index]?.unload?.()
this.#mediaQuery.removeEventListener('change', this.#mediaQueryListener)