UNPKG

@virtualstate/app-history

Version:

Native JavaScript [app-history](https://github.com/WICG/app-history) implementation

17 lines 686 B
import { ok } from "../util.js"; export async function hashChangeExample(appHistory) { const navigate = new Promise((resolve, reject) => { appHistory.addEventListener("navigate", resolve); appHistory.addEventListener("navigateerror", event => reject(event.error)); }); const expectedHash = `#h${Math.random()}`; await appHistory.navigate(expectedHash); const event = await navigate; ok(event); ok(event.hashChange); ok(appHistory.current.url); // console.log(appHistory.current.url); ok(new URL(appHistory.current.url).hash); ok(new URL(appHistory.current.url).hash === expectedHash); } //# sourceMappingURL=hash-change.js.map