Skip to content

<svelte:component> not properly destroyed when inside of an Element with transition:fn #6763

@icalvin102

Description

@icalvin102

Describe the bug

If a <svelte:component> tag is used inside of a element with a svelte transition (like in the code below) and the this prop is changed while the transition is playing then the old component will stay mounted alongside the new one.

{#if open}
  <div transition:fade>
    {#if component}
      <svelte:component this={component} />
    {/if}
  </div>
{/if}

Edit: This behavior also seems to occur if a there is a transition inside the component that is provided to the this prop.

Reproduction

https://svelte.dev/repl/c3000501dc154b88b93cf37c58b350b7?version=3.43.0

To reproduce click the Open button followed by clicking the Confirm buttons.

Only one component should be visible at a time but all components stay mounted.

Remove transition:fade in Container.svelte to get the proper behavior.

Logs

No response

System Info

Linux 5.13.13-arch1-1, Brave Version 1.26.74 Chromium: 91.0.4472.124 (Official Build) (64-bit)

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions