[ci] format

This commit is contained in:
natemoo-re 2023-01-23 18:05:25 +00:00 committed by fredkbot
parent 7325df4121
commit 12a10fe7c5
4 changed files with 10 additions and 6 deletions

View file

@ -19,8 +19,8 @@ test.describe('CSS Sourcemap HMR', () => {
test.skip(isWindows, 'TODO: fix css hmr in windows'); test.skip(isWindows, 'TODO: fix css hmr in windows');
test('removes Astro-injected CSS once Vite-injected CSS loads', async ({ page, astro }) => { test('removes Astro-injected CSS once Vite-injected CSS loads', async ({ page, astro }) => {
const html = await astro.fetch('/').then(res => res.text()); const html = await astro.fetch('/').then((res) => res.text());
// style[data-astro-dev-id] should exist in initial SSR'd markup // style[data-astro-dev-id] should exist in initial SSR'd markup
expect(html).toMatch('data-astro-dev-id'); expect(html).toMatch('data-astro-dev-id');

View file

@ -32,8 +32,8 @@ test.describe('CSS HMR', () => {
}); });
test('removes Astro-injected CSS once Vite-injected CSS loads', async ({ page, astro }) => { test('removes Astro-injected CSS once Vite-injected CSS loads', async ({ page, astro }) => {
const html = await astro.fetch('/').then(res => res.text()); const html = await astro.fetch('/').then((res) => res.text());
// style[data-astro-dev-id] should exist in initial SSR'd markup // style[data-astro-dev-id] should exist in initial SSR'd markup
expect(html).toMatch('data-astro-dev-id'); expect(html).toMatch('data-astro-dev-id');

View file

@ -136,7 +136,7 @@ async function getScriptsAndStyles({ env, filePath }: GetScriptsAndStylesParams)
props: { props: {
type: 'text/css', type: 'text/css',
// Track the ID so we can match it to Vite's injected style later // Track the ID so we can match it to Vite's injected style later
'data-astro-dev-id': viteID(new URL(`.${url}`, env.settings.config.root)) 'data-astro-dev-id': viteID(new URL(`.${url}`, env.settings.config.root)),
}, },
children: content, children: content,
}); });

View file

@ -42,5 +42,9 @@ function isStyle(node: Node): node is HTMLStyleElement {
} }
function isViteInjectedStyle(node: Node): node is HTMLStyleElement { function isViteInjectedStyle(node: Node): node is HTMLStyleElement {
return isStyle(node) && node.getAttribute('type') === 'text/css' && !!node.getAttribute('data-vite-dev-id'); return (
isStyle(node) &&
node.getAttribute('type') === 'text/css' &&
!!node.getAttribute('data-vite-dev-id')
);
} }