mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-13 11:35:28 +00:00
14 lines
399 B
TypeScript
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;
|
|
}
|
|
} |