From d1ec0dad40845843dbe5138b27328a3ef021c622 Mon Sep 17 00:00:00 2001 From: John Factotum <50942278+johnfactotum@users.noreply.github.com> Date: Fri, 19 May 2023 02:44:32 +0800 Subject: [PATCH] Fix initial history state --- view.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/view.js b/view.js index 5d5cbdb..1a8adc3 100644 --- a/view.js +++ b/view.js @@ -123,9 +123,15 @@ export class View extends HTMLElement { } async init({ lastLocation, showTextStart }) { const resolved = lastLocation ? this.resolveNavigation(lastLocation) : null - if (resolved) await this.renderer.goTo(resolved) + if (resolved) { + await this.renderer.goTo(resolved) + this.history.pushState(lastLocation) + } else if (showTextStart) await this.goToTextStart() - else await this.renderer.next() + else { + this.history.pushState(0) + await this.next() + } } #emit(name, detail, cancelable) { return this.dispatchEvent(new CustomEvent(name, { detail, cancelable }))