File tree Expand file tree Collapse file tree 2 files changed +11
-26
lines changed
packages/svelte/tests/runtime-browser/samples/attribute-spreading-with-events Expand file tree Collapse file tree 2 files changed +11
-26
lines changed Original file line number Diff line number Diff line change 1
1
import { test } from '../../assert' ;
2
- const tick = ( ) => Promise . resolve ( ) ;
2
+ import { tick } from 'svelte' ;
3
3
4
4
export default test ( {
5
5
async test ( { assert, target } ) {
6
6
await tick ( ) ;
7
- /** @type {HTMLElement } */
8
- const el = target . querySelector ( '.test' ) ;
9
- el . addEventListener ( 'animationend' , async ( ) => {
10
- await tick ( ) ;
11
- assert . exists ( document . querySelector ( '.result' ) ) ;
12
- } ) ;
7
+ /** @type {HTMLDivElement } */
8
+ const el = target . querySelector ( 'div' ) ;
9
+ const animation_end = new window . AnimationEvent ( 'animationend' ) ;
10
+
11
+ await el . dispatchEvent ( animation_end ) ;
12
+
13
+ await tick ( ) ;
14
+
15
+ assert . htmlEqual ( target . innerHTML , '<div></div> <span>animation ended</span>' ) ;
13
16
}
14
17
} ) ;
Original file line number Diff line number Diff line change 5
5
6
6
<div
7
7
{...obj }
8
- class =" test"
9
8
ontransitionend ={(e ) => {
10
9
// doesnt matter
11
10
}}
16
15
</div >
17
16
18
17
{#if animationEnded }
19
- <span class = " result " >
18
+ <span >
20
19
animation ended
21
20
</span >
22
21
{/if }
23
-
24
- <style >
25
- .test {
26
- width : 10rem ;
27
- height : 10rem ;
28
- background-color : red ;
29
- animation : test-animation 10ms ;
30
- }
31
- @keyframes test-animation {
32
- from {
33
- opacity : 0 ;
34
- }
35
- to {
36
- opacity : 1 ;
37
- }
38
- }
39
- </style >
You can’t perform that action at this time.
0 commit comments