Fix initial history state

This commit is contained in:
John Factotum
2023-05-19 02:44:32 +08:00
parent bafd64f408
commit d1ec0dad40
+8 -2
View File
@@ -123,9 +123,15 @@ export class View extends HTMLElement {
} }
async init({ lastLocation, showTextStart }) { async init({ lastLocation, showTextStart }) {
const resolved = lastLocation ? this.resolveNavigation(lastLocation) : null 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 if (showTextStart) await this.goToTextStart()
else await this.renderer.next() else {
this.history.pushState(0)
await this.next()
}
} }
#emit(name, detail, cancelable) { #emit(name, detail, cancelable) {
return this.dispatchEvent(new CustomEvent(name, { detail, cancelable })) return this.dispatchEvent(new CustomEvent(name, { detail, cancelable }))