Comments (4)
This also kinda explain why position matters. At .length
you are pushing in a completely new position. With splice you are "replacing an old one" so the component at position 2 is not unmounted but the prop is replaced and the same goes with the component inside. Is the same component so bind:this is probably not triggered.
Not sure if this is still a bug tho.
from svelte.
Thanks a lot for spotting this! We can of course provide a unique key when that solves the issue. Still, I guess I'd expect this to work without providing a key too (with less efficient reconciliation).
So leaving this open for the Svelte team to decide if there's action needed (could be a fix, or a warning?).
Attaching our Twitter discussion for context:
https://twitter.com/PaoloRicciuti/status/1782036498780414003
from svelte.
The behavior is the same in Svelte 4, it doesn't work there, too.
I'm inclined to mark this as "works as designed". The reason is that the each array by default is checking the array index for whether or not the whole thing needs to be recreated. Since the indexes only increase, the existing ones never change and so bind:this
has no indication to update.
from svelte.
Yeah, this is working as intended. Using keyed each blocks is always the preferred way to handle stateful content FWIW.
from svelte.
Related Issues (20)
- Svelte 5: Double nested component with array bind leads to ownership_invalid_mutation warning
- Suggestion: Warn when <button> or <a> lack inner text, and recommend to add aria-label
- String containing "</script>" inside the script tag of a components breaks Svelte HOT 4
- $derived rune stops working but not if using $inspect() HOT 9
- Svelte 5: The `on` of `svelte/events` is restricted to use with `Element` only HOT 3
- Svelte 5: input value not updated during hydration
- Svelte 5: Customized built-in elements HOT 3
- svelte:head to allow ordering because meta tags are underneath script tags HOT 4
- Keyframes names scoped don't work correct in css nesting HOT 1
- TS EventHandler param type not matches HOT 2
- [email protected] breaks `svelte-check` HOT 1
- Svelte 5: snippets with multiple default values get incorrectly parsed
- Svelte 5: Syntax error on snippets with inline typing with optional properties HOT 3
- Svelte 5: compiler crash when using function in both event handler and markup
- Runes: Add an idiomatic way to clean up side-effects HOT 5
- Setting class $state property in constructor breaks all tracking HOT 15
- Inconsistent behavior of `let` directive in combination with snippets HOT 3
- Svelte 5: `<tr>` is invalid inside `<table>` HOT 2
- Svelte 5: hydration error on each with 0 elements on the server and some elements on the client
- Memory leak on component unmount HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from svelte.