-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Svelte 5: HMR breaks with conditional rendering within {#if} blocks #12417
Comments
A little further clarification to how this repro is set up, and which files are relevant. Conditional Svelte Component # Example
/src/routes/display-apple.svelte
/src/routes/display-orange.svelte Switch Component - with {#if} block # Example
/src/routes/conditional-with-if.svelte Switch Component - with {#if} block # Example
/src/routes/conditional-with-map.svelte Page Component # Example
/src/routes/+page.svelte |
Likely same underlying reason as for #12403 |
- in certain situations, we need to go back once during hydration to properly capture the start node - we need to adjust the anchor for HMR; we only come across it after hydrating the inner contents fixes #12417
- in certain situations, we need to go back once during hydration to properly capture the start node - we need to adjust the anchor for HMR; we only come across it after hydrating the inner contents fixes #12417
Describe the bug
When an HMR update occurs on a conditionally rendered component, the affected component is removed from the document.
Reproduction
Minimal reproduction: github.com/OllieJT/repro-svelte5-hmr-if-block/
npm run dev
and make note of the rendered page./src/routes/display-apple.svelte
or/src/routes/display-orange.svelte
- I just add text to the element contents.What's interesting is conditional rendering with a component map is unaffected. This appears to specifically be an issue affecting the
{#if}
block.Logs
No relevant logs. `12:35:20 [vite] hmr update /src/routes/display-apple.svelte`
System Info
Severity
blocking all usage of svelte
The text was updated successfully, but these errors were encountered: