Closed OllieJT closed 1 month ago
A little further clarification to how this repro is set up, and which files are relevant.
Conditional Svelte Component Typical svelte component that accepts props.
# Example
/src/routes/display-apple.svelte
/src/routes/display-orange.svelte
Switch Component - with {#if} block
A component that accepts a discriminated union, and renders a component for each case using the {#if}
block.
# Example
/src/routes/conditional-with-if.svelte
Switch Component - with {#if} block
A component that accepts a discriminated union, and renders a component for each case using a component map and <svelte:component />
element.
# Example
/src/routes/conditional-with-map.svelte
Page Component Loops over data, using the switch component to conditionally render the correct component.
# Example
/src/routes/+page.svelte
Likely same underlying reason as for #12403
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
System Info
Severity
blocking all usage of svelte