[ci] format
This commit is contained in:
parent
41afb84057
commit
68066290df
3 changed files with 28 additions and 19 deletions
|
@ -143,18 +143,24 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|||
const links: Promise<any>[] = [];
|
||||
for (const el of doc.querySelectorAll('head link[rel=stylesheet]')) {
|
||||
// Do not preload links that are already on the page.
|
||||
if(!document.querySelector(`[${PERSIST_ATTR}="${el.getAttribute(PERSIST_ATTR)}"], link[rel=stylesheet]`)) {
|
||||
if (
|
||||
!document.querySelector(
|
||||
`[${PERSIST_ATTR}="${el.getAttribute(PERSIST_ATTR)}"], link[rel=stylesheet]`
|
||||
)
|
||||
) {
|
||||
const c = document.createElement('link');
|
||||
c.setAttribute('rel', 'preload');
|
||||
c.setAttribute('as', 'style');
|
||||
c.setAttribute('href', el.getAttribute('href')!);
|
||||
links.push(new Promise<any>(resolve => {
|
||||
links.push(
|
||||
new Promise<any>((resolve) => {
|
||||
['load', 'error'].forEach((evName) => c.addEventListener(evName, resolve));
|
||||
document.head.append(c);
|
||||
}));
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
links.length && await Promise.all(links);
|
||||
links.length && (await Promise.all(links));
|
||||
|
||||
if (fallback === 'animate') {
|
||||
let isAnimating = false;
|
||||
|
|
|
@ -22,7 +22,10 @@ interface ExtractedProps {
|
|||
props: Record<string | number | symbol, any>;
|
||||
}
|
||||
|
||||
const transitionDirectivesToCopyOnIsland = Object.freeze(['data-astro-transition-scope', 'data-astro-transition-persist']);
|
||||
const transitionDirectivesToCopyOnIsland = Object.freeze([
|
||||
'data-astro-transition-scope',
|
||||
'data-astro-transition-persist',
|
||||
]);
|
||||
|
||||
// Used to extract the directives, aka `client:load` information about a component.
|
||||
// Finds these special props and removes them from what gets passed into the component.
|
||||
|
@ -168,7 +171,7 @@ export async function generateHydrateScript(
|
|||
})
|
||||
);
|
||||
|
||||
transitionDirectivesToCopyOnIsland.forEach(name => {
|
||||
transitionDirectivesToCopyOnIsland.forEach((name) => {
|
||||
if (props[name]) {
|
||||
island.props[name] = props[name];
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue