diff --git a/crates/swc_html_codegen/src/lib.rs b/crates/swc_html_codegen/src/lib.rs index aecbad102a30..b13fd2f83d70 100644 --- a/crates/swc_html_codegen/src/lib.rs +++ b/crates/swc_html_codegen/src/lib.rs @@ -234,8 +234,7 @@ where } // A body element's start tag can be omitted if the element is empty, or if the // first thing inside the body element is not ASCII whitespace or a comment, except - // if the first thing inside the body element is a meta, link, script, style, or - // template element. + // if the first thing inside the body element would be parsed differently outside. "body" if n.children.is_empty() || (match n.children.first() { @@ -253,14 +252,17 @@ where })) if *namespace == Namespace::HTML && matches!( &**tag_name, - "meta" + "base" + | "basefont" + | "bgsound" + | "frameset" | "link" + | "meta" + | "noframes" + | "noscript" | "script" | "style" | "template" - | "bgsound" - | "basefont" - | "base" | "title" ) => { diff --git a/crates/swc_html_codegen/tests/fixture/body-noscript/input.html b/crates/swc_html_codegen/tests/fixture/body-noscript/input.html new file mode 100644 index 000000000000..574c19c06a49 --- /dev/null +++ b/crates/swc_html_codegen/tests/fixture/body-noscript/input.html @@ -0,0 +1,8 @@ + + + + + Test + + + diff --git a/crates/swc_html_codegen/tests/fixture/body-noscript/output.html b/crates/swc_html_codegen/tests/fixture/body-noscript/output.html new file mode 100644 index 000000000000..791a10c915aa --- /dev/null +++ b/crates/swc_html_codegen/tests/fixture/body-noscript/output.html @@ -0,0 +1,9 @@ + + + + + Test + + + + \ No newline at end of file diff --git a/crates/swc_html_codegen/tests/fixture/body-noscript/output.min.html b/crates/swc_html_codegen/tests/fixture/body-noscript/output.min.html new file mode 100644 index 000000000000..16ffc89fe005 --- /dev/null +++ b/crates/swc_html_codegen/tests/fixture/body-noscript/output.min.html @@ -0,0 +1,6 @@ + + + Test + + + diff --git a/crates/swc_html_minifier/tests/fixture/text/noscript/output.min.html b/crates/swc_html_minifier/tests/fixture/text/noscript/output.min.html index 93f5f479bebd..b539907e7b6b 100644 --- a/crates/swc_html_minifier/tests/fixture/text/noscript/output.min.html +++ b/crates/swc_html_minifier/tests/fixture/text/noscript/output.min.html @@ -1,4 +1,4 @@ -Document