Files
sapper/runtime/src/app/goto/index.ts
Rich Harris ca034d0857 Support Svelte 3
fixes #546, #551, #552, #554
2019-02-03 14:29:47 -05:00

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
}