mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-19 13:55:21 +00:00
13
runtime/src/app/goto/index.ts
Normal file
13
runtime/src/app/goto/index.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user