Skip to content

Commit 86b3ea8

Browse files
authored
chore: failing test for out-of-order $: execution (#10864)
pre effects, which also contain `$:` statements, are more controlled in legacy mode and should only run once per tick, in their defined order. Flushing them out of order can result in bugs. Related to #10795 and #10787
1 parent 392f7d2 commit 86b3ea8

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { tick } from 'svelte';
2+
import { test } from '../../test';
3+
4+
export default test({
5+
skip: true, // failing test for https://github.com/sveltejs/svelte/issues/10787
6+
html: `<button>3</button>`,
7+
async test({ assert, target }) {
8+
target.querySelector('button')?.click();
9+
await tick();
10+
11+
assert.htmlEqual(target.innerHTML, `<button>1</button>`);
12+
}
13+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<script>
2+
let x = 1;
3+
let y = true;
4+
$: array = y ? [1, 2] : [1];
5+
$: count = array.length === 2 && x ? 1 : 0;
6+
$: sum = count + array.length;
7+
</script>
8+
9+
<button
10+
on:click={() => {
11+
// order is important here: x must be updated before y
12+
// in order to test that $: still runs in the correct order
13+
x = 2;
14+
y = false;
15+
}}>{sum}</button
16+
>

0 commit comments

Comments
 (0)