File tree Expand file tree Collapse file tree 5 files changed +62
-0
lines changed
src/compiler/phases/2-analyze
tests/runtime-runes/samples/transition-static-subtree Expand file tree Collapse file tree 5 files changed +62
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' svelte ' : patch
3
+ ---
4
+
5
+ fix: ensure transitions are applied to nested elements
Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ import { SvelteWindow } from './visitors/SvelteWindow.js';
63
63
import { TaggedTemplateExpression } from './visitors/TaggedTemplateExpression.js' ;
64
64
import { Text } from './visitors/Text.js' ;
65
65
import { TitleElement } from './visitors/TitleElement.js' ;
66
+ import { TransitionDirective } from './visitors/TransitionDirective.js' ;
66
67
import { UpdateExpression } from './visitors/UpdateExpression.js' ;
67
68
import { UseDirective } from './visitors/UseDirective.js' ;
68
69
import { VariableDeclarator } from './visitors/VariableDeclarator.js' ;
@@ -172,6 +173,7 @@ const visitors = {
172
173
SvelteWindow,
173
174
TaggedTemplateExpression,
174
175
Text,
176
+ TransitionDirective,
175
177
TitleElement,
176
178
UpdateExpression,
177
179
UseDirective,
Original file line number Diff line number Diff line change
1
+ /** @import { AST } from '#compiler' */
2
+ /** @import { Context } from '../types' */
3
+
4
+ import { mark_subtree_dynamic } from './shared/fragment.js' ;
5
+
6
+ /**
7
+ * @param {AST.TransitionDirective } node
8
+ * @param {Context } context
9
+ */
10
+ export function TransitionDirective ( node , context ) {
11
+ mark_subtree_dynamic ( context . path ) ;
12
+
13
+ context . next ( ) ;
14
+ }
Original file line number Diff line number Diff line change
1
+ import { flushSync } from '../../../../src/index-client.js' ;
2
+ import { test } from '../../test' ;
3
+
4
+ export default test ( {
5
+ async test ( { assert, raf, target } ) {
6
+ assert . htmlEqual ( target . innerHTML , '<button>Toggle</button><div><span>123</span></div>' ) ;
7
+
8
+ const btn1 = target . querySelector ( 'button' ) ;
9
+ btn1 ?. click ( ) ;
10
+ flushSync ( ) ;
11
+ raf . tick ( 250 ) ;
12
+
13
+ assert . htmlEqual (
14
+ target . innerHTML ,
15
+ '<button>Toggle</button><div><span style="opacity: 0.5;">123</span></div>'
16
+ ) ;
17
+
18
+ flushSync ( ) ;
19
+ raf . tick ( 500 ) ;
20
+
21
+ assert . htmlEqual ( target . innerHTML , '<button>Toggle</button>' ) ;
22
+ }
23
+ } ) ;
Original file line number Diff line number Diff line change
1
+ <script >
2
+ function fade (_ ) {
3
+ return {
4
+ duration: 500 ,
5
+ css : t => ` opacity: ${ t} ` ,
6
+ }
7
+ }
8
+
9
+ let visible = $state (true );
10
+ </script >
11
+
12
+ <button onclick ={() => visible = ! visible }>Toggle</button >
13
+
14
+ {#if visible }
15
+ <div >
16
+ <span transition:fade >123</span >
17
+ </div >
18
+ {/if }
You can’t perform that action at this time.
0 commit comments