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

🐛 BUG: <html> tag is removed when there are element elements or components before it #913

Open
MoustaphaDev opened this issue Dec 18, 2023 · 0 comments
Assignees
Labels
- P2: has workaround Bug, but has workaround (priority)

Comments

@MoustaphaDev
Copy link
Member

MoustaphaDev commented Dec 18, 2023

What version of @astrojs/compiler are you using?

2.3.4

What package manager are you using?

pnpm

What operating system are you using?

Linux

Describe the Bug

When using any element or component before the html tag (or body tag), the html and body tags are removed from the output

Source

<hr /><html lang="en"><body><h1>Astro</h1></body></html>

Current result

$$render`${$$maybeRenderHead($$result)}<hr><h1>Astro</h1>`;

Expected result

$$render`<html lang="en">${$$maybeRenderHead($$result)}<body><hr><h1>Astro</h1></body></html>`

This is how other HTML5 compliant parsers like parse5 handle the source code.

In the stackblitz repro you will see that the elements are somewhat rearranged, but that's the browser's work. See a direct visualization of the issue here

A workaround would be to simply NOT do that 😅

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-sb9voo?file=src%2Fpages%2Findex.astro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P2: has workaround Bug, but has workaround (priority)
Projects
None yet
Development

No branches or pull requests

1 participant