-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: transition parameters are not reactive (#9836)
* test: add tests of transitions in new runtime * fix: move evaluation of props * format * add changeset
- Loading branch information
1 parent
180b332
commit 8a013c4
Showing
6 changed files
with
64 additions
and
5 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 | ||
--- | ||
|
||
A transition's parameters are now evaluated when the transition is initialized. |
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
12 changes: 12 additions & 0 deletions
12
packages/svelte/tests/runtime-runes/samples/transition-evaluation/_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,12 @@ | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
test({ assert, component, target }) { | ||
const div = /** @type {HTMLDivElement & { foo?: number }} */ (target.querySelector('div')); | ||
|
||
assert.equal(div.foo, undefined); | ||
component.foo = 2; | ||
component.visible = false; | ||
assert.equal(div.foo, 2); | ||
} | ||
}); |
12 changes: 12 additions & 0 deletions
12
packages/svelte/tests/runtime-runes/samples/transition-evaluation/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,12 @@ | ||
<script> | ||
const { visible = true, foo = 1 } = $props(); | ||
function bar(node, params) { | ||
node.foo = params; | ||
return () => ({}); | ||
} | ||
</script> | ||
|
||
{#if visible} | ||
<div transition:bar={foo}></div> | ||
{/if} |
14 changes: 14 additions & 0 deletions
14
packages/svelte/tests/runtime-runes/samples/transition-js-initial/_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,14 @@ | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
test({ assert, component, target, raf }) { | ||
component.visible = true; | ||
|
||
const div = /** @type {HTMLDivElement & { foo: number }} */ (target.querySelector('div')); | ||
raf.tick(0); | ||
assert.equal(div.foo, 0); | ||
|
||
raf.tick(50); | ||
assert.equal(div.foo, 0.5); | ||
} | ||
}); |
16 changes: 16 additions & 0 deletions
16
packages/svelte/tests/runtime-runes/samples/transition-js-initial/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,16 @@ | ||
<script> | ||
const { visible = false } = $props(); | ||
function foo(node, params) { | ||
return { | ||
duration: 100, | ||
tick: t => { | ||
node.foo = t; | ||
} | ||
}; | ||
} | ||
</script> | ||
|
||
{#if visible} | ||
<div transition:foo></div> | ||
{/if} |
8a013c4
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-5-preview-svelte.vercel.app
svelte-5-preview.vercel.app
svelte-octane.vercel.app
svelte-5-preview-git-main-svelte.vercel.app