diff options
Diffstat (limited to 'packages/astro/src')
4 files changed, 8 insertions, 8 deletions
diff --git a/packages/astro/src/compiler/transform/doctype.ts b/packages/astro/src/compiler/transform/doctype.ts index 1a0ff39e1..7647c205e 100644 --- a/packages/astro/src/compiler/transform/doctype.ts +++ b/packages/astro/src/compiler/transform/doctype.ts @@ -9,7 +9,7 @@ export default function (_opts: { filename: string; fileID: string }): Transform html: { Element: { enter(node, parent, _key, index) { - if (node.name === '!doctype') { + if (node.name.toLowerCase() === '!doctype') { hasDoctype = true; } if (node.name === 'html' && !hasDoctype) { 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 63ac9fd8d..7db630764 100644 --- a/packages/astro/src/compiler/transform/postcss-scoped-styles/index.ts +++ b/packages/astro/src/compiler/transform/postcss-scoped-styles/index.ts @@ -28,8 +28,7 @@ export const NEVER_SCOPED_TAGS = new Set<string>([ 'noscript', 'script', 'style', - 'title', - '!doctype', + 'title' ]); /** * Scope Rules diff --git a/packages/astro/src/compiler/transform/styles.ts b/packages/astro/src/compiler/transform/styles.ts index 1e459bb7f..e1199e9a6 100644 --- a/packages/astro/src/compiler/transform/styles.ts +++ b/packages/astro/src/compiler/transform/styles.ts @@ -4,13 +4,12 @@ import type { TemplateNode } from '@astrojs/parser'; import crypto from 'crypto'; import { createRequire } from 'module'; import path from 'path'; -import { fileURLToPath } from 'url'; import autoprefixer from 'autoprefixer'; import postcss, { Plugin } from 'postcss'; import postcssKeyframes from 'postcss-icss-keyframes'; import findUp from 'find-up'; import sass from 'sass'; -import { debug, error, LogOptions } from '../../logger.js'; +import { error, LogOptions } from '../../logger.js'; import astroScopedStyles, { NEVER_SCOPED_TAGS } from './postcss-scoped-styles/index.js'; import slash from 'slash'; @@ -222,7 +221,9 @@ export default function transformStyles({ compileOptions, filename, fileID }: Tr } // 2. add scoped HTML classes - if (NEVER_SCOPED_TAGS.has(node.name)) return; // only continue if this is NOT a <script> tag, etc. + if (NEVER_SCOPED_TAGS.has(node.name) || node.name.toLowerCase() === '!doctype') { + return; // only continue if this is NOT a <script> tag, etc. + } // Note: currently we _do_ scope web components/custom elements. This seems correct? injectScopedClassAttribute(node, scopedClass); diff --git a/packages/astro/src/internal/h.ts b/packages/astro/src/internal/h.ts index bcfb4833f..07420a353 100644 --- a/packages/astro/src/internal/h.ts +++ b/packages/astro/src/internal/h.ts @@ -7,8 +7,8 @@ const voidTags = new Set(['area', 'base', 'br', 'col', 'command', 'embed', 'hr', /** Generator for primary h() function */ function* _h(tag: string, attrs: HProps, children: Array<HChild>) { - if (tag === '!doctype') { - yield '<!doctype '; + if (tag.toLowerCase() === '!doctype') { + yield `<${tag} `; if (attrs) { yield Object.keys(attrs).join(' '); } |