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

chore: tweak html tree validation #12618

Merged
merged 8 commits into from
Jul 27, 2024
Merged

chore: tweak html tree validation #12618

merged 8 commits into from
Jul 27, 2024

Conversation

dummdidumm
Copy link
Member

  • relax validation in some places where we know the HTML will not break or only break when using SSR
  • consolidate validation in one place and for better reuse, which results in more cases getting caught at runtime

This deliberately doesn't include validation of elements that are invalid but still render without the browser adjusting the DOM in some way. I think the current validation is flexible/open enough to be enhanced to catch more cases later on like "this is only valid as the first child", if we wanted to.

closes #11941

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

- relax validation in some places where we know the HTML will not break or only break when using SSR
- consolidate validation in one place and for better reuse, which results in more cases getting caught at runtime

closes #11941
Copy link

changeset-bot bot commented Jul 26, 2024

⚠️ No Changeset found

Latest commit: 193faee

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@@ -192,6 +192,14 @@

> %thing% is invalid inside <%parent%>
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we're giving enough diagnostic information here. If I saw this error message...

<tr> is invalid inside <table>

...I would tear my hair out. I think we need some supplemental information at the very least, but it'd be better still if we just handled this case. What would it take for us to do that?

Copy link
Member Author

@dummdidumm dummdidumm Jul 26, 2024

Choose a reason for hiding this comment

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

I poked a bit at it this morning but didn't get very far - just opened a draft PR for visibility #12628

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: Nested form control bindings causes runtime error
4 participants