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

The content of else part in each block repeats #4202

Closed
zwz opened this issue Aug 10, 2019 · 5 comments · Fixed by #4253
Closed

The content of else part in each block repeats #4202

zwz opened this issue Aug 10, 2019 · 5 comments · Fixed by #4253
Labels

Comments

@zwz
Copy link

zwz commented Aug 10, 2019

You can reproduce it by following these steps:

  1. start with sapper-template#rollup

  2. modify the file routes/index.svelte as:

    <script>
    let array = []
    </script>
    {#each array as elem}
    item
    {:else}
    weird
    {/each}
    

    Until now everything works fine. You will see one "weird" on the page.

  3. remove the file routes/_layout.svelte

    After refreshing the page (manually), you will see two "weird"s!

  4. if you append something to the file routes/index.svelte, make it like

    <script>
    let array = []
    </script>
    {#each array as elem}
    item
    {:else}
    weird
    {/each}
    blah blah ...
    

    then everything just works fine again.

@zwz
Copy link
Author

zwz commented Aug 17, 2019

repeated-else-issue.zip

This is a demo project.
Just download and extract it, run npm install && npm run dev.

I have been struggling with it for a few days.
Hope somebody could confirm it is a bug or help me out.

@zwz zwz changed the title The content of else part in each block repeats sometime The content of else part in each block repeats Aug 18, 2019
@zwz
Copy link
Author

zwz commented Nov 9, 2019

I made an online demo for this issue at https://codesandbox.io/s/sapper-minimal-blns7
You will see an extra weird appears above Hello World once you refresh.

@Conduitry
Copy link
Member

This seems to be an issue with hydration. Moving to Svelte repo.

@Conduitry Conduitry transferred this issue from sveltejs/sapper Jan 2, 2020
@Conduitry Conduitry added the bug label Jan 2, 2020
@vipero07
Copy link

vipero07 commented Jan 3, 2020

This doesn't seem to happen in the svelte repl with 3.16.7 or 3.4.1 the version of svelte used in the codesandbox example.

Pretty certain this has to do with removing _layout.svelte in sapper.

@Conduitry
Copy link
Member

Hydration of {#each} {:else} should be fixed in 3.17.0.

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