-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Injecting CSS via <svelte:head> breaks loading +layout css #13086
Comments
Investigation so far: This is because of |
We have a `run_scripts` function which is invoked in case a template block contains a script tag, and that function replaces the script tags (so that they actually run). If such a script tag is first or last in the template, the replacement is not picked up by our `node.first_node/last_node` logic anymore, and so it contains a stale tag. That means on cleanup the remove logic fails. In the case of the referenced issue, it just runs past the script tag till the very end of the head, removing the just added style tag from the new page. Fixes #13086
We have a `run_scripts` function which is invoked in case a template block contains a script tag, and that function replaces the script tags (so that they actually run). If such a script tag is first or last in the template, the replacement is not picked up by our `node.first_node/last_node` logic anymore, and so it contains a stale tag. That means on cleanup the remove logic fails. In the case of the referenced issue, it just runs past the script tag till the very end of the head, removing the just added style tag from the new page. Fixes #13086
We have a `run_scripts` function which is invoked in case a template block contains a script tag, and that function replaces the script tags (so that they actually run). If such a script tag is first or last in the template, the replacement is not picked up by our `node.first_node/last_node` logic anymore, and so it contains a stale tag. That means on cleanup the remove logic fails. In the case of the referenced issue, it just runs past the script tag till the very end of the head, removing the just added style tag from the new page. Fixes #13086
We have a `run_scripts` function which is invoked in case a template block contains a script tag, and that function replaces the script tags (so that they actually run). If such a script tag is first or last in the template, the replacement is not picked up by our `node.first_node/last_node` logic anymore, and so it contains a stale tag. That means on cleanup the remove logic fails. In the case of the referenced issue, it just runs past the script tag till the very end of the head, removing the just added style tag from the new page. Fixes #13086
Describe the bug
One of my pages has the following code. Adding this code prevents the proper CSS loading for all subsequent +layout/+page css files. The
/+layout.svelte?t=1724986125513&svelte&type=style&lang.css
file shows up in the network tab, but the css is never injected into the head of the document.Here's a video showing me navigating from the "Delivery Page" page (where the svelte:head code is) to the "Media" page where the CSS is broken. But when I refresh on the "Media " page, the CSS loads properly.
https://github.com/user-attachments/assets/5c52acd0-8738-4092-b97b-d15b7e2a59f2
Reproduction
Here's a minimal reproduction:
https://stackblitz.com/edit/svelte5-sveltehead-css-issue?file=src%2Froutes%2F%2Blayout.svelte,src%2Froutes%2Fchild1%2F%2Bpage.svelte,src%2Froutes%2Fchild2%2F%2Bpage.svelte,src%2Froutes%2Fchild3%2F%2Bpage.svelte
Here's the real world video of it happening:
2024-08-30.15-59-57.mp4
Logs
No response
System Info
Severity
blocking an upgrade
The text was updated successfully, but these errors were encountered: