diff --git a/src/runtime/index.ts b/src/runtime/index.ts index e890bcf..0c62478 100644 --- a/src/runtime/index.ts +++ b/src/runtime/index.ts @@ -133,7 +133,7 @@ function prepare_route(Page: ComponentConstructor, props: RouteData) { }); } -function navigate(target: Target, id: number) { +function navigate(target: Target, id: number): Promise { if (id) { // popstate or initial navigation cid = id; @@ -299,13 +299,17 @@ export function init(opts: { App: ComponentConstructor, target: Node, routes: Ro export function goto(href: string, opts = { replaceState: false }) { const target = select_route(new URL(href, document.baseURI)); + let promise; if (target) { - navigate(target, null); + promise = navigate(target, null); if (history) history[opts.replaceState ? 'replaceState' : 'pushState']({ id: cid }, '', href); } else { window.location.href = href; + promise = new Promise(f => {}); // never resolves } + + return promise; } export function prefetchRoutes(pathnames: string[]) { diff --git a/test/app/routes/about.html b/test/app/routes/about.html index 605e0db..65ebb57 100644 --- a/test/app/routes/about.html +++ b/test/app/routes/about.html @@ -6,15 +6,21 @@

This is the 'about' page. There's not much here.

-