Skip to content
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

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

Closed
Rich-Harris opened this issue May 3, 2018 · 0 comments
Closed

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

Rich-Harris opened this issue May 3, 2018 · 0 comments
Labels

Comments

@Rich-Harris
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant