File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed
packages/svelte/tests/runtime-runes/samples/attachment-component Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 1+ import { flushSync } from 'svelte' ;
12import { test } from '../../test' ;
23
34export default test ( {
4- ssrHtml : `<div></div>` ,
5- html : `<div>set from component</div>`
5+ ssrHtml : `<button>update</button><div></div>` ,
6+ html : `<button>update</button><div>one</div>` ,
7+
8+ test ( { target, assert } ) {
9+ const button = target . querySelector ( 'button' ) ;
10+
11+ flushSync ( ( ) => button ?. click ( ) ) ;
12+ assert . htmlEqual ( target . innerHTML , '<button>update</button><div>two</div>' ) ;
13+ }
614} ) ;
Original file line number Diff line number Diff line change 11<script >
22 import Child from ' ./Child.svelte' ;
3+
4+ let message = $state (' one' );
5+
6+ function attachment (message ) {
7+ return (node ) => {
8+ node .textContent = message;
9+ };
10+ }
311 </script >
412
5- <Child {@attach (node ) => node.textContent = 'set from component'} />
13+ <button onclick ={() => message = ' two' }>update</button >
14+
15+ <Child {@attach attachment (message )} />
You can’t perform that action at this time.
0 commit comments