Skip to content

Commit 5053ce2

Browse files
committed
test: add guard-derived short-circuit regression
1 parent 0bca1c7 commit 5053ce2

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { test } from '../../test';
2+
import { flushSync } from 'svelte';
3+
4+
export default test({
5+
mode: ['client'],
6+
async test({ target, assert }) {
7+
const button = target.querySelector('button');
8+
9+
flushSync(() => button?.click());
10+
11+
assert.equal(target.textContent?.trim(), 'Trigger');
12+
}
13+
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<script>
2+
let virtualItems = $state([{ index: 0 }, { index: 1 }, { index: 2 }]);
3+
let centerRows = $state([{ depth: 2 }, { depth: 1 }, { depth: 1 }]);
4+
5+
let someChange = $state(false);
6+
$effect(() => {
7+
if (someChange) centerRows = [];
8+
});
9+
</script>
10+
11+
{#each virtualItems as row (row.index)}
12+
{@const centerRow = centerRows[row.index]}
13+
{#if centerRow != undefined && centerRow.depth != undefined && typeof centerRow === "object" && "depth" in centerRow && typeof centerRow.depth === "number"}
14+
{#if centerRow.depth != undefined && centerRow.depth > 0}
15+
Hello World<br />
16+
{/if}
17+
{/if}
18+
{/each}
19+
20+
<button onclick={() => (someChange = true)}>Trigger</button>

0 commit comments

Comments
 (0)