File tree Expand file tree Collapse file tree 4 files changed +39
-9
lines changed
packages/svelte/tests/runtime-runes/samples
event-attribute-delegation-2
event-attribute-delegation-3 Expand file tree Collapse file tree 4 files changed +39
-9
lines changed Original file line number Diff line number Diff line change 1
1
<script >
2
2
import { log } from ' ./log.js' ;
3
- const action = () => {}
4
3
</script >
5
- <div use:action onclick ={() => log .push (' clicked container' )} onkeydown ={() => {}}>
6
- <div use:action onclick ={(e ) => { log .push (' clicked div 1' ) }}>
7
- <div onclick ={(e ) => { log .push (' clicked div 2' ) }}>
8
- <button onclick ={(e ) => { log .push (' clicked button' ); e .stopPropagation () }}>
9
- Button
10
- </button >
11
- </div >
12
- </div >
4
+ <div on:click ={(e ) => { log .push (' clicked div' ) }}>
5
+ <button onclick ={(e ) => { log .push (' clicked button' ); e .stopPropagation () }}>
6
+ Button
7
+ </button >
13
8
</div >
Original file line number Diff line number Diff line change
1
+ import { flushSync } from 'svelte' ;
2
+ import { test } from '../../test' ;
3
+ import { log } from './log.js' ;
4
+
5
+ export default test ( {
6
+ before_test ( ) {
7
+ log . length = 0 ;
8
+ } ,
9
+
10
+ async test ( { assert, target } ) {
11
+ const [ b1 ] = target . querySelectorAll ( 'button' ) ;
12
+
13
+ flushSync ( ( ) => {
14
+ b1 ?. click ( ) ;
15
+ } ) ;
16
+
17
+ await Promise . resolve ( ) ;
18
+ assert . deepEqual ( log , [ 'clicked button' ] ) ;
19
+ }
20
+ } ) ;
Original file line number Diff line number Diff line change
1
+ /** @type {any[] } */
2
+ export const log = [ ] ;
Original file line number Diff line number Diff line change
1
+ <script >
2
+ import { log } from ' ./log.js' ;
3
+ const action = () => {}
4
+ </script >
5
+ <div use:action onclick ={() => log .push (' clicked container' )} onkeydown ={() => {}}>
6
+ <div use:action onclick ={(e ) => { log .push (' clicked div 1' ) }}>
7
+ <div onclick ={(e ) => { log .push (' clicked div 2' ) }}>
8
+ <button onclick ={(e ) => { log .push (' clicked button' ); e .stopPropagation () }}>
9
+ Button
10
+ </button >
11
+ </div >
12
+ </div >
13
+ </div >
You can’t perform that action at this time.
0 commit comments