diff --git a/.changeset/fast-colts-shout.md b/.changeset/fast-colts-shout.md new file mode 100644 index 000000000..40932357e --- /dev/null +++ b/.changeset/fast-colts-shout.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixed bug where a class attribute was added to the doctype diff --git a/packages/astro/src/compiler/transform/postcss-scoped-styles/index.ts b/packages/astro/src/compiler/transform/postcss-scoped-styles/index.ts index 7a038dd7a..a7d20b9d4 100644 --- a/packages/astro/src/compiler/transform/postcss-scoped-styles/index.ts +++ b/packages/astro/src/compiler/transform/postcss-scoped-styles/index.ts @@ -14,8 +14,7 @@ const CSS_SEPARATORS = new Set([' ', ',', '+', '>', '~']); const KEYFRAME_PERCENT = /\d+\.?\d*%/; /** HTML tags that should never get scoped classes */ -export const NEVER_SCOPED_TAGS = new Set(['base', 'body', 'font', 'frame', 'frameset', 'head', 'html', 'link', 'meta', 'noframes', 'noscript', 'script', 'style', 'title']); - +export const NEVER_SCOPED_TAGS = new Set(['base', 'body', 'font', 'frame', 'frameset', 'head', 'html', 'link', 'meta', 'noframes', 'noscript', 'script', 'style', 'title', '!doctype']); /** * Scope Rules * Given a selector string (`.btn>span,.nav>span`), add an additional CSS class to every selector (`.btn.myClass>span.myClass,.nav.myClass>span.myClass`) diff --git a/packages/astro/test/astro-doctype.test.js b/packages/astro/test/astro-doctype.test.js index d0d0db105..0db0135ae 100644 --- a/packages/astro/test/astro-doctype.test.js +++ b/packages/astro/test/astro-doctype.test.js @@ -40,6 +40,14 @@ DType('Automatically prepends the standards mode doctype', async () => { assert.ok(html.startsWith(''), 'Doctype always included'); }); +DType('No attributes added when doctype is provided by user', async () => { + const result = await runtime.load('/provided'); + if (result.error) throw new Error(result.error); + + const html = result.contents.toString('utf-8'); + assert.ok(html.startsWith(''), 'Doctype always included'); +}); + DType.skip('Preserves user provided doctype', async () => { const result = await runtime.load('/preserve'); if (result.error) throw new Error(result.error); diff --git a/packages/astro/test/fixtures/astro-doctype/src/pages/provided.astro b/packages/astro/test/fixtures/astro-doctype/src/pages/provided.astro new file mode 100644 index 000000000..8544ba765 --- /dev/null +++ b/packages/astro/test/fixtures/astro-doctype/src/pages/provided.astro @@ -0,0 +1,9 @@ +--- +let title = 'My Site'; +--- + + + + {title} +

Hello world

+ \ No newline at end of file