mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-14 20:14:39 +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 }) {
|
export default function goto(href: string, opts = { replaceState: false }) {
|
||||||
const target = select_route(new URL(href, document.baseURI));
|
const target = select_route(new URL(href, document.baseURI));
|
||||||
let promise;
|
|
||||||
|
|
||||||
if (target) {
|
if (target) {
|
||||||
promise = navigate(target, null).then(() => {});
|
history[opts.replaceState ? 'replaceState' : 'pushState']({ id: cid }, '', href);
|
||||||
if (history) history[opts.replaceState ? 'replaceState' : 'pushState']({ id: cid }, '', href);
|
return navigate(target, null).then(() => {});
|
||||||
} else {
|
|
||||||
location.href = href;
|
|
||||||
promise = new Promise(f => {}); // never resolves
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return promise;
|
location.href = href;
|
||||||
|
return new Promise(f => {}); // never resolves
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user