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

14 lines
399 B
TypeScript

import { select_target, prefetching, set_prefetching, hydrate_target } from '../app';
import { Target } from '../types';
export default function prefetch(href: string) {
const target: Target = select_target(new URL(href, document.baseURI));
if (target) {
if (!prefetching || href !== prefetching.href) {
set_prefetching(href, hydrate_target(target));
}
return prefetching.promise;
}
}