mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-13 19:45:26 +00:00
13 lines
430 B
TypeScript
13 lines
430 B
TypeScript
import { history, select_target, navigate, cid } from '../app';
|
|
|
|
export default function goto(href: string, opts = { replaceState: false }) {
|
|
const target = select_target(new URL(href, document.baseURI));
|
|
|
|
if (target) {
|
|
history[opts.replaceState ? 'replaceState' : 'pushState']({ id: cid }, '', href);
|
|
return navigate(target, null).then(() => {});
|
|
}
|
|
|
|
location.href = href;
|
|
return new Promise(f => {}); // never resolves
|
|
} |