[ci] format

This commit is contained in:
matthewp 2023-07-21 20:29:15 +00:00 committed by astrobot-houston
parent 274e675328
commit c65da5f1cd
2 changed files with 12 additions and 9 deletions

View file

@ -48,11 +48,14 @@ const { fallback = 'animate' } = Astro.props as Props;
const swap = () => document.documentElement.replaceWith(doc.documentElement); const swap = () => document.documentElement.replaceWith(doc.documentElement);
// Wait on links to finish, to prevent FOUC // Wait on links to finish, to prevent FOUC
const links = Array.from(doc.querySelectorAll('head link[rel=stylesheet]')).map(link => new Promise(resolve => { const links = Array.from(doc.querySelectorAll('head link[rel=stylesheet]')).map(
(link) =>
new Promise((resolve) => {
const c = link.cloneNode(); const c = link.cloneNode();
['load', 'error'].forEach(evName => c.addEventListener(evName, resolve)); ['load', 'error'].forEach((evName) => c.addEventListener(evName, resolve));
document.head.append(c); document.head.append(c);
})); })
);
if (links.length) { if (links.length) {
await Promise.all(links); await Promise.all(links);
} }

View file

@ -128,9 +128,9 @@ test.describe('View Transitions', () => {
}); });
test('Stylesheets in the head are waited on', async ({ page, astro }) => { test('Stylesheets in the head are waited on', async ({ page, astro }) => {
page.addListener('console', data => { page.addListener('console', (data) => {
console.log(data) console.log(data);
}) });
// Go to page 1 // Go to page 1
await page.goto(astro.resolveUrl('/one')); await page.goto(astro.resolveUrl('/one'));