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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

@const clashes with animate #7124

Closed
janosh opened this issue Jan 12, 2022 · 5 comments
Closed

@const clashes with animate #7124

janosh opened this issue Jan 12, 2022 · 5 comments
Labels
bug compiler Changes relating to the compiler

Comments

@janosh
Copy link
Contributor

janosh commented Jan 12, 2022

Describe the bug

Very cool that {@const} is out now! Thanks again to @tanhauhau in #6413! 馃憤

There's a problem using it together with animate. The following snippet raises

An element that uses the animate directive must be the sole child of a keyed each block
<script>
  import { flip } from 'svelte/animate'
  const indices = [...Array(10).keys()]
</script>

  {#each indices as idx (idx)}
    {@const idxp1 = idx + 1}
    <li animate:flip>
      {idxp1}
    </li>
  {/each}

Reproduction

REPL

Logs

No response

System Info

Irrelevant

Severity

blocking an upgrade

@bluwy bluwy added bug compiler Changes relating to the compiler labels Jan 12, 2022
@ghostdevv
Copy link
Member

Seems that this issue is caused because when the const tags are stripped from the children nodes of the each block, it leaves behind a text node of tabs and line breaks, when you inline everything to remove the line breaks it compiles correctly {#each indices as idx (idx)}{@const idxp1 = idx + 1}<li animate:flip>

@gtm-nayan
Copy link
Contributor

Possibly related #5477 and #5415

@bluwy
Copy link
Member

bluwy commented Jan 13, 2022

Also probably related: #3999

@ghostdevv
Copy link
Member

This is fixed now @janosh and can be closed

@janosh
Copy link
Contributor Author

janosh commented Jan 15, 2022

Thanks!

@janosh janosh closed this as completed Jan 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug compiler Changes relating to the compiler
Projects
None yet
Development

No branches or pull requests

4 participants