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

Svelte uses same yield content when it's in a if block #231

Closed
PaulBGD opened this issue Dec 30, 2016 · 3 comments · Fixed by #242
Closed

Svelte uses same yield content when it's in a if block #231

PaulBGD opened this issue Dec 30, 2016 · 3 comments · Fixed by #242
Labels

Comments

@PaulBGD
Copy link
Member

PaulBGD commented Dec 30, 2016

I created a test repo with more info: https://github.com/PaulBGD/svelte-uses-same-yield

Comes down to:
This bug only occurs when there is a 2nd component with a yield in it and the 1st component has an if statement that uses the 2nd component in each block. The content of the yield will be the same passed from the 1st if block.

@PaulBGD
Copy link
Member Author

PaulBGD commented Dec 30, 2016

This is a pretty major issue, as the following common code doesn't work:

{{#if false}}
<Component>Hello</Component>
{{else}}
<Component>Goodbye</Component>
{{/if}}

Shows Hello, the string Goodbye isn't even included in the final bundle.

@PaulBGD
Copy link
Member Author

PaulBGD commented Jan 4, 2017

So changing

const yieldName = generator.current.getUniqueName( `render${name}YieldFragment` );
to generator.current.parent.getUniqueName fixes the issue, because before the different yield blocks were getting the same name and so svelte was only using the 1st one.

The only thing is, I don't understand why we need to use the parent there because I'm not super familiar with this piece of code. Any advice @Rich-Harris?

@Rich-Harris Rich-Harris added the bug label Jan 4, 2017
Rich-Harris added a commit that referenced this issue Jan 4, 2017
make yield renderer names globally unique
@Rich-Harris
Copy link
Member

Fixed in 1.6.3, thanks (the answer was that the names need to be globally unique — it just so happened that in that case using the parent fragment's name maker had the same effect)

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.

2 participants