File tree Expand file tree Collapse file tree 3 files changed +28
-9
lines changed
src/compiler/phases/3-transform/client/visitors
tests/runtime-runes/samples/each-without-as-keyed Expand file tree Collapse file tree 3 files changed +28
-9
lines changed Original file line number Diff line number Diff line change @@ -298,18 +298,13 @@ export function EachBlock(node, context) {
298298 let key_function = b . id ( '$.index' ) ;
299299
300300 if ( node . metadata . keyed ) {
301- const pattern = node . context ;
302301 const expression = /** @type {Expression } */ (
303302 context . visit ( /** @type {Expression } */ ( node . key ) , key_state )
304303 ) ;
305- /** @type {Pattern[] } */
306- const args = [ ] ;
307- if ( pattern ) {
308- args . push ( pattern ) ;
309- }
310- if ( key_uses_index ) {
311- args . push ( index ) ;
312- }
304+
305+ const args = [ node . context ?? b . id ( '$$' ) ] ;
306+ if ( key_uses_index ) args . push ( index ) ;
307+
313308 key_function = b . arrow ( args , expression ) ;
314309 }
315310
Original file line number Diff line number Diff line change 1+ import { flushSync } from 'svelte' ;
2+ import { test } from '../../test' ;
3+
4+ export default test ( {
5+ html : `<button>update</button><p>3</p><p>2</p><p>1</p>` ,
6+
7+ async test ( { target, assert } ) {
8+ const [ button ] = target . querySelectorAll ( 'button' ) ;
9+
10+ flushSync ( ( ) => button . click ( ) ) ;
11+ assert . htmlEqual ( target . innerHTML , `<button>update</button><p>1</p><p>2</p><p>3</p>` ) ;
12+ }
13+ } ) ;
Original file line number Diff line number Diff line change 1+ <script >
2+ let items = $state ([{ id: 3 }, { id: 2 }, { id: 1 }]);
3+ </script >
4+
5+ <button onclick ={() => items = [{ id: 1 }, { id: 2 }, { id: 3 }]}>
6+ update
7+ </button >
8+
9+ {#each items , i (items [i ].id )}
10+ <p >{items[i ].id}</p>
11+ {/each}
You can’t perform that action at this time.
0 commit comments