Skip to content

<svelte:component> updates props before itself #16135

@buhrmi

Description

@buhrmi

Describe the bug

When using <svelte:component>, and changing the component at the same time as its props, the old component updates with the new props, before the component is replaced with the new component.

In the provided reproduction, when clicking the "Swap Components" button, the console will show:

init prop1 prop1
update prop1 undefined
init prop2 prop2

Expected Behavior: The old component should not receive the new props, and the console output should be

init prop1 prop1
init prop2 prop2

Reproduction

https://svelte.dev/playground/hello-world?version=5.34.1#H4sIAAAAAAAAE5VSwW6DMAz9lSiaVCpVoOaIaKVpl913HDtQMFW0kETEXTch_n1JgJJ2ReoukNjPL89-7qgsGqApfQUhFDmrVlQkgoojVGu6oTUXYGj63lH80Q7nAjY-Vj1rHZsvEOhih8LAvXipJIJES0MzU7Zc4z6XOfJGqxbJi2r0ltStasgqTkp3G0tXNyh2hWIByuIEDCAl7VNkR54MFgiRZ19PAN0qbeZk5-I5uug2JTn1h5y6aO9r6pMskStJUB2PAhxZtCZjGa9JFLy4Gzq5pHMM5Xj9U2KS0bkDm15mOe0HxPgDYWCZbXuXLewjZLOfLJmHL7OZrovj2HP0JBlyhxOibVrJUvDyc9fN3ff7t3Oh50GbLBnAttA6jfCNNMX2BP1mYWNCg6935iazsDXOxtA335yz1LcQedueuDQaSowuo9h4690iBFPwU0zHufWPy2eL8tl_5bMH5LNJPvsrn43y2Y38D3sruDhzWdG0Luwi9b_timIT6gMAAA==

Logs

System Info

N/A

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions