-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ensure transitions are applied to nested elements (#14080)
- Loading branch information
Showing
5 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'svelte': patch | ||
--- | ||
|
||
fix: ensure transitions are applied to nested elements |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
packages/svelte/src/compiler/phases/2-analyze/visitors/TransitionDirective.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** @import { AST } from '#compiler' */ | ||
/** @import { Context } from '../types' */ | ||
|
||
import { mark_subtree_dynamic } from './shared/fragment.js'; | ||
|
||
/** | ||
* @param {AST.TransitionDirective} node | ||
* @param {Context} context | ||
*/ | ||
export function TransitionDirective(node, context) { | ||
mark_subtree_dynamic(context.path); | ||
|
||
context.next(); | ||
} |
23 changes: 23 additions & 0 deletions
23
packages/svelte/tests/runtime-runes/samples/transition-static-subtree/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { flushSync } from '../../../../src/index-client.js'; | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
async test({ assert, raf, target }) { | ||
assert.htmlEqual(target.innerHTML, '<button>Toggle</button><div><span>123</span></div>'); | ||
|
||
const btn1 = target.querySelector('button'); | ||
btn1?.click(); | ||
flushSync(); | ||
raf.tick(250); | ||
|
||
assert.htmlEqual( | ||
target.innerHTML, | ||
'<button>Toggle</button><div><span style="opacity: 0.5;">123</span></div>' | ||
); | ||
|
||
flushSync(); | ||
raf.tick(500); | ||
|
||
assert.htmlEqual(target.innerHTML, '<button>Toggle</button>'); | ||
} | ||
}); |
18 changes: 18 additions & 0 deletions
18
packages/svelte/tests/runtime-runes/samples/transition-static-subtree/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<script> | ||
function fade(_) { | ||
return { | ||
duration: 500, | ||
css: t => `opacity: ${t}`, | ||
} | ||
} | ||
let visible = $state(true); | ||
</script> | ||
|
||
<button onclick={() => visible = !visible}>Toggle</button> | ||
|
||
{#if visible} | ||
<div> | ||
<span transition:fade>123</span> | ||
</div> | ||
{/if} |