compiler
compiler copied to clipboard
🐛 BUG: `<html>` tag is removed when there are element elements or components before it
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