File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed
packages/svelte/tests/runtime-runes/samples/binding-update-while-focused-3 Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ import { tick } from 'svelte' ;
2+ import { test } from '../../test' ;
3+
4+ export default test ( {
5+ mode : [ 'client' , 'hydrate' ] ,
6+
7+ async test ( { assert, target } ) {
8+ const [ input ] = target . querySelectorAll ( 'input' ) ;
9+
10+ input . focus ( ) ;
11+ input . value = 'Ab' ;
12+ input . dispatchEvent ( new InputEvent ( 'input' , { bubbles : true } ) ) ;
13+
14+ await tick ( ) ;
15+
16+ assert . equal ( input . value , 'AB' ) ;
17+ assert . htmlEqual ( target . innerHTML , `<input /><p>AB</p>` ) ;
18+
19+ input . focus ( ) ;
20+ input . value = 'ABc' ;
21+ input . dispatchEvent ( new InputEvent ( 'input' , { bubbles : true } ) ) ;
22+
23+ await tick ( ) ;
24+
25+ assert . equal ( input . value , 'ABC' ) ;
26+ assert . htmlEqual ( target . innerHTML , `<input /><p>ABC</p>` ) ;
27+ }
28+ } ) ;
Original file line number Diff line number Diff line change 1+ <script >
2+ let text = $state (' A' );
3+ </script >
4+
5+ <input bind:value ={() => text , (v ) => text = v .toUpperCase ()} />
6+ <p >{text }</p >
You can’t perform that action at this time.
0 commit comments