[ci] format
This commit is contained in:
parent
6ad91bd80d
commit
06c5d51b37
1 changed files with 3 additions and 4 deletions
|
@ -15,7 +15,7 @@ function shouldPreload({ href }: { href: string }) {
|
||||||
window.location.pathname !== url.pathname &&
|
window.location.pathname !== url.pathname &&
|
||||||
!preloaded.has(href)
|
!preloaded.has(href)
|
||||||
);
|
);
|
||||||
} catch { }
|
} catch {}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ async function preloadHref(link: HTMLAnchorElement) {
|
||||||
return fetch(el.href);
|
return fetch(el.href);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
} catch { }
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PrefetchOptions {
|
export interface PrefetchOptions {
|
||||||
|
@ -115,8 +115,7 @@ export default function prefetch({
|
||||||
});
|
});
|
||||||
|
|
||||||
requestIdleCallback(() => {
|
requestIdleCallback(() => {
|
||||||
const links = [...document.querySelectorAll<HTMLAnchorElement>(selector)]
|
const links = [...document.querySelectorAll<HTMLAnchorElement>(selector)].filter(shouldPreload);
|
||||||
.filter(shouldPreload);
|
|
||||||
links.forEach(observe);
|
links.forEach(observe);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue