File tree Expand file tree Collapse file tree 3 files changed +62
-0
lines changed
packages/svelte/tests/runtime-runes/samples/if-transition-undefined Expand file tree Collapse file tree 3 files changed +62
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' svelte ' : patch
3
+ ---
4
+
5
+ fix: allow transition undefined payload
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 : `<button>show</button><button>animate</button>` ,
6
+
7
+ async test ( { assert, target } ) {
8
+ const [ btn1 , btn2 ] = target . querySelectorAll ( 'button' ) ;
9
+
10
+ flushSync ( ( ) => {
11
+ btn1 . click ( ) ;
12
+ } ) ;
13
+
14
+ assert . htmlEqual (
15
+ target . innerHTML ,
16
+ `<button>show</button><button>animate</button><h1>Hello\n!</h1>`
17
+ ) ;
18
+
19
+ flushSync ( ( ) => {
20
+ btn1 . click ( ) ;
21
+ } ) ;
22
+
23
+ assert . htmlEqual ( target . innerHTML , `<button>show</button><button>animate</button>` ) ;
24
+
25
+ flushSync ( ( ) => {
26
+ btn2 . click ( ) ;
27
+ } ) ;
28
+
29
+ assert . htmlEqual ( target . innerHTML , `<button>show</button><button>animate</button>` ) ;
30
+
31
+ flushSync ( ( ) => {
32
+ btn1 . click ( ) ;
33
+ } ) ;
34
+
35
+ assert . htmlEqual (
36
+ target . innerHTML ,
37
+ `<button>show</button><button>animate</button><h1 style="opacity: 0;">Hello\n!</h1>`
38
+ ) ;
39
+ }
40
+ } ) ;
Original file line number Diff line number Diff line change
1
+ <script >
2
+ import { fade } from ' svelte/transition' ;
3
+
4
+ let show = $state (false );
5
+ let animate = $state (false );
6
+
7
+ function maybe (node , animate ) {
8
+ console .log (' maybe - animate?' , animate);
9
+ if (animate) return fade (node);
10
+ }
11
+ </script >
12
+
13
+ <button onclick ={() => show = ! show }>show</button ><button onclick ={() => animate = ! animate }>animate</button >
14
+
15
+ {#if show }
16
+ <h1 transition:maybe ={animate }>Hello {name }!</h1 >
17
+ {/if }
You can’t perform that action at this time.
0 commit comments