UNPKG

shelving

Version:

Toolkit for using data in JavaScript.

20 lines (19 loc) 660 B
import { URLStore } from "../../store/URLStore.js"; import { requireURL } from "../../util/url.js"; /** * Store the current navigation state (URL only). * - TODO: switch to the browser Navigation API when broadly supported. */ export class NavigationStore extends URLStore { constructor(url = "/", base) { super(url, base); } forward(possible) { this.value = requireURL(possible, this.base, this.forward); window.history.pushState(null, "", this.value); } redirect(possible) { this.value = requireURL(possible, this.base, this.redirect); window.history.replaceState(null, "", this.value); } }