Skip to content

Missing <body> tag if astro finds an unrecognized head tag #982

@molszanski

Description

@molszanski

Astro Info

Astro                    v4.5.0
Node                     v18.17.1
System                   macOS (arm64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

Chrome

Describe the Bug

Input:

<!DOCTYPE html>
<html lang="en">
	<head>
		<title>document</title>
		<!-- Delete next line and body will be red -->
		<lol href='lol'/>
	</head>
	<body style="background-color:red">
		<slot />
	</body>
</html>

Output

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>document</title>
    <lol test="123"></lol>
    <div>
  1231231231
      <span>Hello Astro</span>
    </div>
  </html>

Notice the missing </head> and <body> elements.

Minimal Repro:
https://stackblitz.com/edit/github-zkwgaq-g5un8g?file=src%2Fpages%2Findex.astro&file=src%2Flayouts%2FLayout.astro&on=stackblitz

What's the expected result?

valid html. Astro should omit tags it doesn't recogdnize / understand

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-zkwgaq-g5un8g?file=src%2Fpages%2Findex.astro&file=src%2Flayouts%2FLayout.astro&on=stackblitz

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageIssue needs to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions