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

Runtime error with nested components, {{#if}}s, and {{yield}} #643

Closed
TehShrike opened this issue Jun 15, 2017 · 7 comments · Fixed by #735
Closed

Runtime error with nested components, {{#if}}s, and {{yield}} #643

TehShrike opened this issue Jun 15, 2017 · 7 comments · Fixed by #735
Labels

Comments

@TehShrike
Copy link
Member

Very similar to #625 - observed in Svelte 1.22.3.

I got a reproduction in the REPL here but then downloaded it locally to fiddle with it some more, so you can find an even slimmer reproduction in https://github.com/TehShrike/svelte-1-22-3-nested-yield-issue-repro

When the state changes and causes some elements to be cleaned up, an error is thrown Uncaught TypeError: Cannot read property 'unmount' of null

Seems to happen when there is a loop that contains a component with {{yield}} inside of an {{#if}} block, but only when there is another Svelte component nested inside of the yielding component.

@PaulBGD
Copy link
Member

PaulBGD commented Jun 16, 2017

Hitting the same error in one of my projects using Svelte when I upgraded from a 5 month old version. Only difference is that while it's the same error (calling unmount on null fragment) my project doesn't use loops. Your example is much smaller than mine, so I'll try to debug it and figure out what's going on.

@TehShrike
Copy link
Member Author

yeah, it may be possible to trigger the issue with a destroy() or otherwise causing the nested components to not be needed any more. I only spent a little time slimming down the reproduction case.

@PaulBGD
Copy link
Member

PaulBGD commented Jun 16, 2017

Found it:

block.builders.destroy.addLine(
`${if_name}{
${name}.unmount();
${name}.destroy();
}`

${name}.unmount needs to be added to the unmount block.

PaulBGD added a commit to PaulBGD/svelte that referenced this issue Jun 16, 2017
Rich-Harris added a commit that referenced this issue Jun 17, 2017
Rich-Harris added a commit that referenced this issue Jun 17, 2017
@laszbalo
Copy link

laszbalo commented Jun 26, 2017

Is this issue fixed? Tried to run the Modal example from the guide, but got the same error. Tried it locally, and also in the REPL. I am on version 1.23.4.

@TehShrike
Copy link
Member Author

My reproduction cases above don't throw errors any more with 1.27.0.

@PaulBGD
Copy link
Member

PaulBGD commented Aug 1, 2017

I've updated to latest version in my large project and no issues.

Rich-Harris added a commit that referenced this issue Aug 4, 2017
don't throw error if component is destroyed twice
@Rich-Harris
Copy link
Member

Fixed in 1.28

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

Successfully merging a pull request may close this issue.

4 participants