Comments (8)
I tell a lie. HMR is a factor here, insofar as it's what accounts for the discrepancy between repros, but it's actually any effect inside an {#each ...}
loop, not just the HMR effect. Remarkable that it wasn't surfaced sooner.
It was introduced in #11197 (demo), and is fixed in #11254.
from svelte.
I haven't figured out why, exactly, but this is related to HMR — if I disable it in the Vite config, things work as expected. That's why you can't reproduce it in the REPL
from svelte.
It doesn't happen in the production build, it probably has something to do with HMR
from svelte.
It doesn't happen in the production build, it probably has something to do with HMR
Yes, I can confirm this, which may explain why the issue is not reproduced in Svelte5-REPL
.
from svelte.
Can you really use the value itself as a key? I've always thought it was not at all expected but it may be a relic from my Vue days since it isn't mentioned in the docs.
Anyway if you {#each array.entries() as [i, item] (i)}
it starts working as expected.
from svelte.
Can you really use the value itself as a key? I've always thought it was not at all expected but it may be a relic from my Vue days since it isn't mentioned in the docs.
Yes you can
This has always been one of Svelte's differentiators.
The key can be any object, but strings and numbers are recommended since they allow identity to persist when the objects themselves change.
from svelte.
Yes you can
Yes although I have trouble seeing what's the under the hood difference in this case VS not using at all a key? Since the keys should also be modified along the values? Worth noting that both repros work as expected without key.
from svelte.
Anyway if you
{#each array.entries() as [i, item] (i)}
it starts working as expected.
No, I tried that version and it produces the same effect.
Using the same value is just to simplify reproduction.
I can adapt this to a new reproduction of that syntax if you need it.
Here you go:
StackBlitz-svelte-5.0.0-next.108 (with k,v syntax)
from svelte.
Related Issues (20)
- Accessibility warning: href shouldn't be required when aria-disabled="true"
- Svelte 5: confusing behaviour with syntactically invalid attribute expressions HOT 2
- Add rune to more easily combine reactive values and state objects HOT 5
- Passing a Writable as prop to a component doesn't allow "$" access HOT 2
- Svelte 5: dynamic class name not supported on SVG
- Svelte 5: Monkeypatching introduced in #11610 has broken array_prototype.lastIndexOf()
- Svelte version @5.0.0-next.140 breaks Svelte-dnd-action HOT 9
- DOM does not update when using array of objects in $state.frozen() HOT 4
- Svelte 5: onanimationend event doesn't get called under these specific circumstances. HOT 1
- Svelte v5 (maybe v4 too?) incorrectly removes CSS selectors alleging they are unused HOT 9
- Disable paste rather then copy in the tutorial. HOT 2
- Immer JS doesn't work with svelte runes HOT 5
- 5.0.0-next.138 breaks nested global CSS-attribute selectors
- 5.0.0-next.140 blocks pre-render capabilities of $effect.pre() HOT 6
- Svelte action update doesn't trigger on classes HOT 4
- Svelte 5: CSS custom property wrapper is implemented incorrectly HOT 5
- svelte 5: gotpointercapture and lostpointercapture not paresed correctly
- Anchor Tags Triggering Old URLs in Android Chrome HOT 6
- `bind` updates are too late HOT 7
- Svelte 5: Mutation warning when assigning non enumerable properties HOT 7
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.