mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-12 03:05:12 +00:00
small tweak
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user