Skip to content

fix: ensure undefined attributes are removed during hydration #16178

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 4 commits into from
Jun 17, 2025

Conversation

floriskn
Copy link
Contributor

Attributes set server-side but undefined on the client should be removed during hydration.
This ensures expected cleanup behavior and resolves a mismatch between SSR and client-side rendering.

Fixes #16184

floriskn added 2 commits June 16, 2025 11:52
Attributes that are `undefined` on the client should be removed during hydration,
even if their value hasn't changed compared to `prev_value`.
Copy link

changeset-bot bot commented Jun 16, 2025

🦋 Changeset detected

Latest commit: 574def1

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

@svelte-docs-bot
Copy link

@7nik
Copy link
Contributor

7nik commented Jun 16, 2025

Please, add a test that fails without this fix. Propably it should go to the hydration folder, you can at the input-value-changed test as example of what you need.

@floriskn
Copy link
Contributor Author

I’ve added the test under hydration named removes-undefined-attributes. It will fail without the fix, confirming the issue is properly covered.

Copy link
Contributor

Playground

pnpm add https://pkg.pr.new/svelte@16178

Copy link
Member

@Rich-Harris Rich-Harris left a comment

Choose a reason for hiding this comment

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

thank you!

@Rich-Harris Rich-Harris merged commit 579d0e6 into sveltejs:main Jun 17, 2025
10 checks passed
@github-actions github-actions bot mentioned this pull request Jun 17, 2025
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.

Attributes set to undefined are not removed during hydration (spread and direct bindings)
3 participants