File tree Expand file tree Collapse file tree 5 files changed +50
-2
lines changed
tests/runtime-runes/samples/dynamic-if-component-transition Expand file tree Collapse file tree 5 files changed +50
-2
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " svelte " : patch
3
+ ---
4
+
5
+ fix: improve global transition outro handling
Original file line number Diff line number Diff line change @@ -691,7 +691,8 @@ function if_block_transition(transition) {
691
691
transition . f ( ( ) => {
692
692
const c = /** @type {Set<import('./types.js').Transition> } */ ( consequent_transitions ) ;
693
693
c . delete ( transition ) ;
694
- if ( c . size === 0 ) {
694
+ // If the block has changed to falsy and has transitions
695
+ if ( ! block . v && c . size === 0 ) {
695
696
const consequent_effect = block . ce ;
696
697
execute_effect ( /** @type {import('./types.js').EffectSignal } */ ( consequent_effect ) ) ;
697
698
}
@@ -702,7 +703,8 @@ function if_block_transition(transition) {
702
703
transition . f ( ( ) => {
703
704
const a = /** @type {Set<import('./types.js').Transition> } */ ( alternate_transitions ) ;
704
705
a . delete ( transition ) ;
705
- if ( a . size === 0 ) {
706
+ // If the block has changed to truthy and has transitions
707
+ if ( block . v && a . size === 0 ) {
706
708
const alternate_effect = block . ae ;
707
709
execute_effect ( /** @type {import('./types.js').EffectSignal } */ ( alternate_effect ) ) ;
708
710
}
Original file line number Diff line number Diff line change
1
+ <script >
2
+ import { fade } from ' svelte/transition' ;
3
+ let show = $state (true );
4
+ </script >
5
+
6
+ <h1 >Outside</h1 >
7
+
8
+ {#if show }
9
+ <button onclick ={()=> show = false } transition:fade |global ={{ duration : 100 }}>Hide</button >
10
+ {/if }
Original file line number Diff line number Diff line change
1
+ import { test } from '../../test' ;
2
+ import { flushSync } from 'svelte' ;
3
+
4
+ export default test ( {
5
+ async test ( { assert, target, raf } ) {
6
+ const btn = target . querySelector ( 'button' ) ;
7
+
8
+ raf . tick ( 0 ) ;
9
+
10
+ flushSync ( ( ) => {
11
+ btn ?. click ( ) ;
12
+ } ) ;
13
+
14
+ assert . htmlEqual ( target . innerHTML , `<h1>Outside</h1><button>Hide</button>` ) ;
15
+
16
+ raf . tick ( 100 ) ;
17
+
18
+ assert . htmlEqual ( target . innerHTML , `<h1>Outside</h1>` ) ;
19
+ }
20
+ } ) ;
Original file line number Diff line number Diff line change
1
+ <script >
2
+ import Component from " ./Component.svelte"
3
+ let shown = $state (false );
4
+ </script >
5
+
6
+ {#if shown }
7
+ Nothing
8
+ {:else }
9
+ <svelte:component this ={Component } />
10
+ {/if }
11
+
You can’t perform that action at this time.
0 commit comments