Don't append a class attribute to the doctype (#284)
* Don't append a class attribute to the doctype Fixes #282 * Add changeset
This commit is contained in:
parent
ee5b1ac12f
commit
46871d2d4a
4 changed files with 23 additions and 2 deletions
5
.changeset/fast-colts-shout.md
Normal file
5
.changeset/fast-colts-shout.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Fixed bug where a class attribute was added to the doctype
|
|
@ -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<string>(['base', 'body', 'font', 'frame', 'frameset', 'head', 'html', 'link', 'meta', 'noframes', 'noscript', 'script', 'style', 'title']);
|
||||
|
||||
export const NEVER_SCOPED_TAGS = new Set<string>(['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`)
|
||||
|
|
|
@ -40,6 +40,14 @@ DType('Automatically prepends the standards mode doctype', async () => {
|
|||
assert.ok(html.startsWith('<!doctype html>'), '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 html>'), 'Doctype always included');
|
||||
});
|
||||
|
||||
DType.skip('Preserves user provided doctype', async () => {
|
||||
const result = await runtime.load('/preserve');
|
||||
if (result.error) throw new Error(result.error);
|
||||
|
|
9
packages/astro/test/fixtures/astro-doctype/src/pages/provided.astro
vendored
Normal file
9
packages/astro/test/fixtures/astro-doctype/src/pages/provided.astro
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
let title = 'My Site';
|
||||
---
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head><title>{title}</title></head>
|
||||
<body><h1>Hello world</h1></body>
|
||||
</html>
|
Loading…
Reference in a new issue