Skip to content

Commit d893d92

Browse files
committed
on second thoughts
1 parent 5cd5edf commit d893d92

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script>
2+
let { count = 0 } = $props();
3+
</script>
4+
5+
<span>{count}</span>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { test } from '../../test';
2+
3+
// Tests that fallback value is propagated up correctly when the inner component
4+
// uses a prop it does not write to but has a fallback value
5+
export default test({
6+
accessors: false, // so that prop actually becomes $.prop and not $.prop_source
7+
html: `<button>0</button><span>0</span>`,
8+
9+
async test({ assert, target }) {
10+
const btn = target.querySelector('button');
11+
12+
await btn?.click();
13+
14+
assert.htmlEqual(target.innerHTML, `<button>1</button><span>1</span>`);
15+
},
16+
17+
error: `Cannot use fallback values with bind:`
18+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<script>
2+
import Counter from './Counter.svelte';
3+
4+
let bound = $state();
5+
</script>
6+
7+
<button on:click={() => bound = 1}>{bound}</button>
8+
9+
<Counter bind:count={bound} />

0 commit comments

Comments
 (0)