From c66f2e65d91aa893ca40dfdaf583cc1f8b494d85 Mon Sep 17 00:00:00 2001 From: John Factotum <50942278+johnfactotum@users.noreply.github.com> Date: Mon, 31 Jul 2023 11:45:39 +0800 Subject: [PATCH] Fix navigation history not working after reopening book Also remove renderer element when closing --- view.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/view.js b/view.js index 82f03da..da49f17 100644 --- a/view.js +++ b/view.js @@ -88,15 +88,17 @@ export class View extends HTMLElement { #searchResults = new Map() isFixedLayout = false lastLocation - history = new History() + history constructor() { super() + } + async open(book) { + this.history = new History() this.history.addEventListener('popstate', ({ detail }) => { const resolved = this.resolveNavigation(detail.state) this.renderer.goTo(resolved) }) - } - async open(book) { + this.book = book this.language = languageInfo(book.metadata?.language) @@ -130,13 +132,14 @@ export class View extends HTMLElement { this.#root.append(this.renderer) } close() { - this.renderer?.destroy?.() + this.renderer?.destroy() + this.renderer?.remove() this.#sectionProgress = null this.#tocProgress = null this.#pageProgress = null this.#searchResults = new Map() this.lastLocation = null - this.history = new History() + this.history = null } goToTextStart() { return this.goTo(this.book.landmarks