Skip to content

chore: improve SSR parent element validation #13158

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

Merged
merged 1 commit into from
Sep 6, 2024
Merged

chore: improve SSR parent element validation #13158

merged 1 commit into from
Sep 6, 2024

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented Sep 6, 2024

The current logic is wonky, if we don't have a parent_tag we should still continue to validate the element.

Copy link

changeset-bot bot commented Sep 6, 2024

🦋 Changeset detected

Latest commit: 956f027

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

@trueadm
Copy link
Contributor Author

trueadm commented Sep 6, 2024

Going to merge this as it seems uncontroversial and likely just an oversight.

@trueadm trueadm merged commit 0332abb into main Sep 6, 2024
9 checks passed
@trueadm trueadm deleted the valid-ssr branch September 6, 2024 22:09
Rich-Harris added a commit that referenced this pull request Sep 15, 2024
Rich-Harris added a commit that referenced this pull request Sep 15, 2024
Rich-Harris added a commit that referenced this pull request Sep 16, 2024
dummdidumm added a commit that referenced this pull request Nov 26, 2024
This reverts #13255 / #13158, and helps with the validation error part of #14120

The revert is justified because people should be free to render a component in isolation and then append it somewhere where they know the rendered output is valid. If someone renders a tag at the top level that is invalid without a certain parent (which itself is an edge case), then the likelihood that this is done on purpose is much higher than that it's done by accident.
dummdidumm added a commit that referenced this pull request Nov 26, 2024
This reverts #13255 / #13158, and helps with the validation error part of #14120

If you would have a component like this...
```svelte
<td>hi there</td>
```
...and then render it on the server via our `render` function like this:
```js
const result = render(Main);
```
...then right now you get an error saying that `td` is not valid at this position. But that doesn't seem right, because we should give people the benefit of the doubt: It may very well be that someone renders such a component and then correctly puts it into a `tr` tag themselves on the server (another example is rendering a full html document like in #14120).

All the other validation where there's a known parent (X not valid inside Y) is untouched by this.

Doing this as cleanup prior to tackling #13331
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.

1 participant