fix: read index as a source in legacy keyed each block (#14208)

Fixes #14203
migrate-conflict-runes
Paolo Ricciuti 2 months ago committed by GitHub
parent ea0d80e195
commit 53af138d58
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: read index as a source in legacy keyed each block

@ -196,7 +196,7 @@ export function EachBlock(node, context) {
// forbidden in runes mode
return b.member(
each_node_meta.array_name ? b.call(each_node_meta.array_name) : collection,
index,
(flags & EACH_INDEX_REACTIVE) !== 0 ? get_value(index) : index,
true
);
}
@ -208,7 +208,7 @@ export function EachBlock(node, context) {
const left = b.member(
each_node_meta.array_name ? b.call(each_node_meta.array_name) : collection,
index,
(flags & EACH_INDEX_REACTIVE) !== 0 ? get_value(index) : index,
true
);

@ -0,0 +1,5 @@
<script>
export let item;
console.log(item);
item = 1;
</script>

@ -0,0 +1,9 @@
import { test } from '../../test';
export default test({
async test({ assert, target, logs }) {
const p = target.querySelector('p');
assert.equal(p?.innerHTML, '1');
assert.deepEqual(logs, [0]);
}
});

@ -0,0 +1,10 @@
<script>
import Component from './Component.svelte';
const items = [0];
</script>
{#each items as item, idx(item)}
<Component bind:item />
{/each}
<p>{items}</p>
Loading…
Cancel
Save