diff --git a/templates/src/client/goto/index.ts b/templates/src/client/goto/index.ts index 0f58786..29757ed 100644 --- a/templates/src/client/goto/index.ts +++ b/templates/src/client/goto/index.ts @@ -1,16 +1,13 @@ -import { select_route, navigate, cid } from '../app'; +import { history, select_route, navigate, cid } from '../app'; export default function goto(href: string, opts = { replaceState: false }) { const target = select_route(new URL(href, document.baseURI)); - let promise; if (target) { - promise = navigate(target, null).then(() => {}); - if (history) history[opts.replaceState ? 'replaceState' : 'pushState']({ id: cid }, '', href); - } else { - location.href = href; - promise = new Promise(f => {}); // never resolves + history[opts.replaceState ? 'replaceState' : 'pushState']({ id: cid }, '', href); + return navigate(target, null).then(() => {}); } - return promise; + location.href = href; + return new Promise(f => {}); // never resolves } \ No newline at end of file