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

feat: improve ssr html mismatch validation #10658

Merged
merged 5 commits into from
Feb 28, 2024
Merged

feat: improve ssr html mismatch validation #10658

merged 5 commits into from
Feb 28, 2024

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented Feb 27, 2024

This provides HTML validation for during DEV when we server side render the content. If any errors are found we console.error both on the server and on the client (we inject a <script> tag with the console.error into the head).

Copy link

changeset-bot bot commented Feb 27, 2024

🦋 Changeset detected

Latest commit: 28d5bf4

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

Copy link
Member

@dummdidumm dummdidumm left a comment

Choose a reason for hiding this comment

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

Looks great! A few small tweaks, other than that 👍

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
'which may result in content being shifted around and will likely result in a hydration mismatch.';
// eslint-disable-next-line no-console
console.error(message);
payload.head.out += `<script>console.error(${message})</script>`;
Copy link

Choose a reason for hiding this comment

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

Missing quotes around ${message}?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It’s already a string though?

Copy link

@thebjorn thebjorn Mar 2, 2024

Choose a reason for hiding this comment

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

yes, but you're generating code (the script tag), and in code strings must be quoted (you probably need to sanitize the message for the quotes you'll be using too...)

Copy link
Member

Choose a reason for hiding this comment

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

You're right, published a fix

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.

None yet

3 participants