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

Client side script inside layout file makes html lang attribute disappear #660

Closed
1 task done
riccardolardi opened this issue Nov 24, 2022 · 11 comments · Fixed by #666
Closed
1 task done

Client side script inside layout file makes html lang attribute disappear #660

riccardolardi opened this issue Nov 24, 2022 · 11 comments · Fixed by #666
Assignees
Labels
- P3: minor bug An edge case that only affects very specific usage (priority)

Comments

@riccardolardi
Copy link

riccardolardi commented Nov 24, 2022

What version of astro are you using?

1.6.11

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

yarn

What operating system are you using?

Mac

Describe the Bug

It seems using a <script> inside the layout which declares the html element will make the lang attribute disappear.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-xuenvq?file=src/layouts/Layout.astro

Participation

  • I am willing to submit a pull request for this issue.
@deeprobin
Copy link

Can repro.

@JerryWu1234
Copy link

mark

@bluwy
Copy link
Member

bluwy commented Nov 28, 2022

Seems like the entire html tag disappears entirely when checking the network request. And this seems similar to withastro/astro#5483. I'm not sure if adding a script before the html makes sense though, maybe it's nice if Astro could sort it down. Marking as a minor bug for now.

@bluwy bluwy added the - P3: minor bug An edge case that only affects very specific usage (priority) label Nov 28, 2022
@JerryWu1234
Copy link

image
Because astro@compiler appears, an error that lost the tag

@jasikpark
Copy link
Contributor

I'm not sure if adding a script before the html makes sense though, maybe it's nice if Astro could sort it down.

I think it makes sense for Astro to support it, since the default for components is top-level scripts and styles associated with the component. this is a weird edgecase, but isn't it the same sort of dx?

@bluwy bluwy transferred this issue from withastro/astro Dec 6, 2022
@natemoo-re natemoo-re self-assigned this Dec 7, 2022
natemoo-re added a commit that referenced this issue Dec 9, 2022
natemoo-re added a commit that referenced this issue Dec 14, 2022
* fix(#660): allow script before HTML

* chore: add changeset

* fix: remove style from logic (already works)

* chore: add doctype

Co-authored-by: Nate Moore <[email protected]>
@Jarmos-san
Copy link

I've recently stumbled across this bug on my website as well and here's the source code particularly responsible for generating the base template. Is there any way I can debug and perhaps identify what the root cause of the issue is?

@skilar
Copy link

skilar commented Mar 9, 2024

Looks like this is caused not just by the script tag but also including styles before the html tag. That should help your issue, @Jarmos-san.

@Jarmos-san
Copy link

@skilar that fixed the issue! Thanks for it. I'm curious, what was wrong with the code there?

@skilar
Copy link

skilar commented Mar 13, 2024

I'm not sure what the issue is, @Jarmos-san, seems like there's still a bug in Astro.

@tvarwig
Copy link

tvarwig commented Apr 29, 2024

Having same issue, astro 4.6.3

@PaulineNemchak
Copy link

PaulineNemchak commented Aug 11, 2024

For those who have this issue, according to docs you should include scripts and styles inside of html tags: https://docs.astro.build/en/basics/layouts/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P3: minor bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants