File tree Expand file tree Collapse file tree 4 files changed +45
-1
lines changed
src/compiler/phases/3-transform/client/visitors
tests/runtime-runes/samples/state-in-template Expand file tree Collapse file tree 4 files changed +45
-1
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " svelte " : patch
3+ ---
4+
5+ fix: allow runes for variable declarations in the template
Original file line number Diff line number Diff line change @@ -3223,5 +3223,6 @@ export const template_visitors = {
32233223 node : b . id ( '$.document' )
32243224 } ) ;
32253225 } ,
3226- CallExpression : javascript_visitors_runes . CallExpression
3226+ CallExpression : javascript_visitors_runes . CallExpression ,
3227+ VariableDeclaration : javascript_visitors_runes . VariableDeclaration
32273228} ;
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 : `<form><input name="name"><button>Add</button></form>` ,
6+
7+ async test ( { assert, target } ) {
8+ const btn = target . querySelector ( 'button' ) ;
9+
10+ flushSync ( ( ) => {
11+ btn ?. click ( ) ;
12+ } ) ;
13+
14+ assert . htmlEqual (
15+ target . innerHTML ,
16+ `<form><input name="name"><button>Add</button></form><div></div>`
17+ ) ;
18+ }
19+ } ) ;
Original file line number Diff line number Diff line change 1+ <script >
2+ import { Set } from ' svelte/reactivity' ;
3+ const set = new Set ();
4+ </script >
5+
6+ <form onsubmit ={e => {
7+ e .preventDefault ();
8+ const data = new FormData (e .target );
9+ const state = $state ({ name: data .get (' name' ) });
10+ set .add (state );
11+ e .target .reset ();
12+ }}>
13+ <input name =" name" />
14+ <button >Add</button >
15+ </form >
16+
17+ {#each set as item }
18+ <div >{item .name }</div >
19+ {/each }
You can’t perform that action at this time.
0 commit comments