mirror of https://github.com/sveltejs/svelte
fix: transition parameters are not reactive (#9836)
* test: add tests of transitions in new runtime * fix: move evaluation of props * format * add changesetpull/10008/head
parent
180b3322b2
commit
8a013c4cc6
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
A transition's parameters are now evaluated when the transition is initialized.
|
@ -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);
|
||||
}
|
||||
});
|
@ -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}
|
@ -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);
|
||||
}
|
||||
});
|
@ -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}
|
Loading…
Reference in new issue