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

callback for each item in {#each} #15349

Closed
Nyx2022 opened this issue Feb 21, 2025 · 3 comments
Closed

callback for each item in {#each} #15349

Nyx2022 opened this issue Feb 21, 2025 · 3 comments

Comments

@Nyx2022
Copy link

Nyx2022 commented Feb 21, 2025

Describe the problem

i'm using {#each} to render a list,and i wanna process the new generated dom element after one item has processed finish,but now there maybe no way to do this

Describe the proposed solution

add a callback attr to {#each} to execute function and cna get all new generated dom

Importance

i cannot use svelte without it

@brunnerh
Copy link
Member

There is no guarantee that any DOM will be generated at all.
Also, #each is fairly bloated already ({#each expression as name, index (key)}) and adding additional stuff to it would not improve the situation.

If you need access to DOM elements, you can define an action on a wrapper element in the #each or use bind:this (you would need to bind to an array/object via an index/key).

@Nyx2022
Copy link
Author

Nyx2022 commented Feb 21, 2025

ok,thank you,i will try the action to check if it can realise my need

@Conduitry
Copy link
Member

Closing. Actions and bind:this are the ways to do this. We don't want to add an {#each}-specific syntax for something we already have.

@Conduitry Conduitry closed this as not planned Won't fix, can't repro, duplicate, stale Feb 22, 2025
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

No branches or pull requests

3 participants