Skip to content

Commit 6af3fc4

Browse files
committed
cleanup
1 parent 702d7ba commit 6af3fc4

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

.changeset/clever-chefs-relate.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: allow transition undefined payload
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { flushSync } from 'svelte';
2+
import { test } from '../../test';
3+
4+
export default test({
5+
html: `<button>show</button><button>animate</button>`,
6+
7+
async test({ assert, target }) {
8+
const [btn1, btn2] = target.querySelectorAll('button');
9+
10+
flushSync(() => {
11+
btn1.click();
12+
});
13+
14+
assert.htmlEqual(
15+
target.innerHTML,
16+
`<button>show</button><button>animate</button><h1>Hello\n!</h1>`
17+
);
18+
19+
flushSync(() => {
20+
btn1.click();
21+
});
22+
23+
assert.htmlEqual(target.innerHTML, `<button>show</button><button>animate</button>`);
24+
25+
flushSync(() => {
26+
btn2.click();
27+
});
28+
29+
assert.htmlEqual(target.innerHTML, `<button>show</button><button>animate</button>`);
30+
31+
flushSync(() => {
32+
btn1.click();
33+
});
34+
35+
assert.htmlEqual(
36+
target.innerHTML,
37+
`<button>show</button><button>animate</button><h1 style="opacity: 0;">Hello\n!</h1>`
38+
);
39+
}
40+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<script>
2+
import { fade } from 'svelte/transition';
3+
4+
let show = $state(false);
5+
let animate = $state(false);
6+
7+
function maybe(node, animate) {
8+
console.log('maybe - animate?', animate);
9+
if (animate) return fade(node);
10+
}
11+
</script>
12+
13+
<button onclick={() => show = !show}>show</button><button onclick={() => animate = !animate}>animate</button>
14+
15+
{#if show}
16+
<h1 transition:maybe={animate}>Hello {name}!</h1>
17+
{/if}

0 commit comments

Comments
 (0)