Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task
molszanski opened this issue Mar 11, 2024 · 9 comments
Open
1 task

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

molszanski opened this issue Mar 11, 2024 · 9 comments
Labels
needs triage Issue needs to be triaged

Comments

@molszanski
Copy link

molszanski commented Mar 11, 2024

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.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Mar 11, 2024
@cdtut
Copy link

cdtut commented Mar 11, 2024

Put this in <head> and head tag won't be generated in build. You have to remove inner {} then it will work. But sometimes it is needed for conditionals inside loop. It was working in 4.0.6 stopped working in 4.5.0.

If there is any problem the build should fail instead of output files without head.

{[1, 2, 3].map(() => <>
    {<meta name="" content="" />}
</>)}

@bluwy bluwy transferred this issue from withastro/astro Mar 12, 2024
@bluwy
Copy link
Member

bluwy commented Mar 12, 2024

The compiled output seems to be incorrect where the body is not rendered:

// ...
return $$render`<html lang="en">
	<head>

		<title>document</title>

		<!-- Delete next line and body will be red -->
		${$$renderHead($$result)}</head><lol href="lol"></lol>
	
	

		${$$renderSlot($$result,$$slots["default"])}
	</html>`;
}, '<stdin>', undefined);
// ...

@cdtut
Copy link

cdtut commented Mar 12, 2024

@bluwy is that the same cause of bug I found?

@cdtut
Copy link

cdtut commented Mar 13, 2024

Bug caused by astro 4.2.2 it works in 4.2.1.

@MoustaphaDev
Copy link
Member

It should get fixed by #939

@cdtut
Copy link

cdtut commented Mar 15, 2024

@MoustaphaDev the bug I reported should be fixed by that too?

The PR is 2 months old is something blocking merge?

@MoustaphaDev
Copy link
Member

MoustaphaDev commented Mar 16, 2024

Sorry for the late response, I haven't checked but the PR fixes several issues like that, so hopefully. I'll check if it does early next week and let you know!
And no there's nothing major blocking it, just needs more testing. I'll hopefully be able to get it over the line next week

@cdtut
Copy link

cdtut commented Mar 24, 2024

@MoustaphaDev I would like upgrade to latest version if you can check if this fixes the issue.

@MoustaphaDev
Copy link
Member

MoustaphaDev commented Mar 29, 2024

Hey @cdtut, I didn't get to work on the PR unfortunately, and probably won't be able to next week too.
Sorry for the inconvenience, hope somebody will be able to pick this up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

4 participants