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

fix: ssr comments in head elements that require raw content #10936

Merged
merged 8 commits into from
Apr 15, 2024

Conversation

DanMB
Copy link
Contributor

@DanMB DanMB commented Mar 26, 2024

Fixes #10935 - HTML comments being added to <title> is annoying, but adding it to <style> and <script> can down right break the entire site, this fixes it the same way the SSR comments were removed from the <textarea> value

Note: I had an issue with creating the test, if i placed the elements inside the <svelte:head> component the test would not fail, even though the _actual-head.html and _expected-head.html did not match up. I've made the test without <svelte:head> so that it actually fails and succeeds and expected.

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

Copy link

changeset-bot bot commented Mar 26, 2024

🦋 Changeset detected

Latest commit: 22cac41

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@@ -64,6 +64,8 @@ export const VoidElements = new Set([
'wbr'
]);

export const RawTextElements = new Set(['textarea', 'script', 'style', 'title']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please can you put these in constants.js where all the others are? Plus it doesn't need to be a Set, an array here would be slightly faster than a Set as there are so few elements in it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I have moved and changed it now. I had just used the same method as the VoidElements set that was above.

@DanMB DanMB requested a review from trueadm April 13, 2024 07:09
@trueadm trueadm merged commit d061f2f into sveltejs:main Apr 15, 2024
0 of 2 checks passed
@vercel vercel bot temporarily deployed to Preview – svelte-dev April 15, 2024 11:11 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Svelte 5: SSR comments in <title>
2 participants