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) {
691691 transition . f ( ( ) => {
692692 const c = /** @type {Set<import('./types.js').Transition> } */ ( consequent_transitions ) ;
693693 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 ) {
695696 const consequent_effect = block . ce ;
696697 execute_effect ( /** @type {import('./types.js').EffectSignal } */ ( consequent_effect ) ) ;
697698 }
@@ -702,7 +703,8 @@ function if_block_transition(transition) {
702703 transition . f ( ( ) => {
703704 const a = /** @type {Set<import('./types.js').Transition> } */ ( alternate_transitions ) ;
704705 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 ) {
706708 const alternate_effect = block . ae ;
707709 execute_effect ( /** @type {import('./types.js').EffectSignal } */ ( alternate_effect ) ) ;
708710 }
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