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

Handle whitespace inside #each with animation #5477

Merged

Conversation

ehrencrona
Copy link
Contributor

@ehrencrona ehrencrona commented Sep 30, 2020

Fixes #5415: If there is stray whitespace inside an #each block that contains an animating element, strip the whitespace out during parsing. This makes sure that the check for whether there is only a single animating child passes.

I guess this means there's a risk that the semantics change subtly if animating inline blocks: you might expect them to be separated by whitespace but they won't be. On the other hand, since we don't support having more than one element animating it's kind of unavoidable. One could conceivably fix this by adding a <span> around the whole output, but I can't overview the consequences of that.

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with npm test and lint the project with npm run lint

@ehrencrona
Copy link
Contributor Author

ehrencrona commented Oct 28, 2020

This was a while ago now, but can we merge? It feels like a fairly safe change.

@stale
Copy link

stale bot commented Jun 26, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale-bot label Jun 26, 2021
@stale stale bot removed the stale-bot label Jun 26, 2021
@stale stale bot removed the stale-bot label Jun 27, 2021
@ehrencrona ehrencrona force-pushed the 5415-whitespace-in-each-with-animation branch from 88cea82 to ad7b1fd Compare July 30, 2021 13:48
@ehrencrona
Copy link
Contributor Author

@benmccann No worries. I rebased it now; seems to still work.

@benmccann
Copy link
Member

Thanks for rebasing @ehrencrona. As a heads up, @tanhauhau had suggested discussing this PR at tomorrow's maintainer's meeting if you'd like to join

@ghostdevv
Copy link
Member

This could possible fix/help fix #7124

Copy link
Member

@tanhauhau tanhauhau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've moved the test to a validator test to validate there's no compile error

@tanhauhau tanhauhau merged commit a4e4027 into sveltejs:master Jan 15, 2022
nevilm-lt pushed a commit to nevilm-lt/svelte that referenced this pull request Mar 14, 2022
* Strip out whitespace inside each when it has an animation

* remove accidentally committed file

* lint

* add test to validate no error

* update changelog

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
Co-authored-by: tanhauhau <lhtan93@gmail.com>
Co-authored-by: Tan Li Hau <tanhauhau@users.noreply.github.com>
nevilm-lt pushed a commit to nevilm-lt/svelte that referenced this pull request Apr 21, 2022
* Strip out whitespace inside each when it has an animation

* remove accidentally committed file

* lint

* add test to validate no error

* update changelog

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
Co-authored-by: tanhauhau <lhtan93@gmail.com>
Co-authored-by: Tan Li Hau <tanhauhau@users.noreply.github.com>
nevilm-lt pushed a commit to nevilm-lt/svelte that referenced this pull request Apr 21, 2022
* Strip out whitespace inside each when it has an animation

* remove accidentally committed file

* lint

* add test to validate no error

* update changelog

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
Co-authored-by: tanhauhau <lhtan93@gmail.com>
Co-authored-by: Tan Li Hau <tanhauhau@users.noreply.github.com>
nevilm-lt pushed a commit to nevilm-lt/svelte that referenced this pull request Apr 22, 2022
* Strip out whitespace inside each when it has an animation

* remove accidentally committed file

* lint

* add test to validate no error

* update changelog

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
Co-authored-by: tanhauhau <lhtan93@gmail.com>
Co-authored-by: Tan Li Hau <tanhauhau@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error when using animate flip if there is no space in front of each block
6 participants