From 46d8f649d540a3dc242bff25fb48c8d4caa66b6d Mon Sep 17 00:00:00 2001 From: natemoo-re Date: Mon, 23 Jan 2023 18:05:25 +0000 Subject: [PATCH] [ci] format --- packages/astro/e2e/css-sourcemaps.test.js | 4 ++-- packages/astro/e2e/css.test.js | 4 ++-- packages/astro/src/core/render/dev/index.ts | 2 +- packages/astro/src/runtime/client/hmr.ts | 6 +++++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/astro/e2e/css-sourcemaps.test.js b/packages/astro/e2e/css-sourcemaps.test.js index 07cea4cb0..919d3c864 100644 --- a/packages/astro/e2e/css-sourcemaps.test.js +++ b/packages/astro/e2e/css-sourcemaps.test.js @@ -19,8 +19,8 @@ test.describe('CSS Sourcemap HMR', () => { test.skip(isWindows, 'TODO: fix css hmr in windows'); 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 expect(html).toMatch('data-astro-dev-id'); diff --git a/packages/astro/e2e/css.test.js b/packages/astro/e2e/css.test.js index 745a540ee..7c2527499 100644 --- a/packages/astro/e2e/css.test.js +++ b/packages/astro/e2e/css.test.js @@ -32,8 +32,8 @@ test.describe('CSS HMR', () => { }); 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 expect(html).toMatch('data-astro-dev-id'); diff --git a/packages/astro/src/core/render/dev/index.ts b/packages/astro/src/core/render/dev/index.ts index 7ea008d69..92d374d3e 100644 --- a/packages/astro/src/core/render/dev/index.ts +++ b/packages/astro/src/core/render/dev/index.ts @@ -136,7 +136,7 @@ async function getScriptsAndStyles({ env, filePath }: GetScriptsAndStylesParams) props: { type: 'text/css', // 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, }); diff --git a/packages/astro/src/runtime/client/hmr.ts b/packages/astro/src/runtime/client/hmr.ts index b71c39990..b4c6acb88 100644 --- a/packages/astro/src/runtime/client/hmr.ts +++ b/packages/astro/src/runtime/client/hmr.ts @@ -42,5 +42,9 @@ function isStyle(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') + ); }