fix(ui): prevent console error when leaving reader (#956)
This commit is contained in:
@@ -360,7 +360,9 @@ class View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
expand() {
|
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) {
|
if (this.#column) {
|
||||||
const side = this.#vertical ? 'height' : 'width'
|
const side = this.#vertical ? 'height' : 'width'
|
||||||
const otherSide = this.#vertical ? 'width' : 'height'
|
const otherSide = this.#vertical ? 'width' : 'height'
|
||||||
@@ -415,8 +417,8 @@ class View {
|
|||||||
get overlayer() {
|
get overlayer() {
|
||||||
return this.#overlayer
|
return this.#overlayer
|
||||||
}
|
}
|
||||||
destroy() {
|
disconnectedCallback() {
|
||||||
if (this.document) this.#observer.unobserve(this.document.body)
|
this.#observer.disconnect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -665,7 +667,7 @@ export class Paginator extends HTMLElement {
|
|||||||
}
|
}
|
||||||
#createView() {
|
#createView() {
|
||||||
if (this.#view) {
|
if (this.#view) {
|
||||||
this.#view.destroy()
|
this.#view.disconnectedCallback()
|
||||||
this.#container.removeChild(this.#view.element)
|
this.#container.removeChild(this.#view.element)
|
||||||
}
|
}
|
||||||
this.#view = new View({
|
this.#view = new View({
|
||||||
@@ -1118,9 +1120,9 @@ export class Paginator extends HTMLElement {
|
|||||||
focusView() {
|
focusView() {
|
||||||
this.#view.document.defaultView.focus()
|
this.#view.document.defaultView.focus()
|
||||||
}
|
}
|
||||||
destroy() {
|
disconnectedCallback() {
|
||||||
this.#observer.unobserve(this)
|
this.#observer.disconnect();
|
||||||
this.#view.destroy()
|
this.#view?.disconnectedCallback()
|
||||||
this.#view = null
|
this.#view = null
|
||||||
this.sections[this.#index]?.unload?.()
|
this.sections[this.#index]?.unload?.()
|
||||||
this.#mediaQuery.removeEventListener('change', this.#mediaQueryListener)
|
this.#mediaQuery.removeEventListener('change', this.#mediaQueryListener)
|
||||||
|
|||||||
Reference in New Issue
Block a user