Skip to content

Spread props on dynamic components fail if no initial value #1413

@Rich-Harris

Description

@Rich-Harris

Bit of an edge case here...

If you have a <svelte:component> whose this doesn't have a value, and it has spread properties, then any updates will fail because the initial spread 'levels' have not been set. REPL

<button on:click="updateProps()">click me</button>
<svelte:component this={undefined} {...props}/>

{#if error}
  <pre>{error.stack}</pre>
{/if}

<script>
  export default {
    data() {
      return {
        props: {}
      };
    },
    
    methods: {
      updateProps() {
        try {
          this.set({ props: {} });
        } catch (error) {
          this.set({ error });
        }
      }
    }
  };
</script>

Interestingly, the this.set({ error }) in that example also fails, because always Svelte tries to recalculate spread levels, even if nothing has changed. Should also get fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions