-
-
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: support dynamic transition functions (#9844)
* fix: support dynamic transition functions * add test * lint * load dynamic code lazily load dynamic code lazily load dynamic code lazily
- Loading branch information
Showing
10 changed files
with
137 additions
and
37 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: support dynamic transition functions |
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
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
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
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
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
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
25 changes: 25 additions & 0 deletions
25
packages/svelte/tests/runtime-runes/samples/dynamic-transition/_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,25 @@ | ||
import { flushSync } from 'svelte'; | ||
import { test } from '../../test'; | ||
import { log } from './log.js'; | ||
|
||
export default test({ | ||
before_test() { | ||
log.length = 0; | ||
}, | ||
|
||
async test({ assert, target }) { | ||
const [b1, b2] = target.querySelectorAll('button'); | ||
|
||
flushSync(() => { | ||
b1.click(); | ||
}); | ||
|
||
assert.deepEqual(log, ['transition 2']); | ||
|
||
flushSync(() => { | ||
b2.click(); | ||
}); | ||
|
||
assert.deepEqual(log, ['transition 2', 'transition 1', 'transition 1']); | ||
} | ||
}); |
2 changes: 2 additions & 0 deletions
2
packages/svelte/tests/runtime-runes/samples/dynamic-transition/log.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,2 @@ | ||
/** @type {any[]} */ | ||
export const log = []; |
33 changes: 33 additions & 0 deletions
33
packages/svelte/tests/runtime-runes/samples/dynamic-transition/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,33 @@ | ||
<script> | ||
import { log } from './log.js'; | ||
function transition1() { | ||
log.push('transition 1') | ||
return { | ||
tick() { | ||
} | ||
} | ||
} | ||
function transition2() { | ||
log.push('transition 2') | ||
return { | ||
tick() { | ||
} | ||
} | ||
} | ||
let toggle = $state(false); | ||
let toggleTransition = $state(false); | ||
const derived = $derived(toggleTransition ? transition1 : transition2) | ||
</script> | ||
|
||
|
||
<button on:click={() => toggle = !toggle}>{toggle}</button> | ||
<button on:click={() => toggleTransition = !toggleTransition}>{toggleTransition}</button> | ||
|
||
{#if toggle}<div transition:derived></div>{/if} | ||
|
fd78acf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
svelte-5-preview – ./sites/svelte-5-preview
svelte-octane.vercel.app
svelte-5-preview.vercel.app
svelte-5-preview-svelte.vercel.app
svelte-5-preview-git-main-svelte.vercel.app