mirror of https://github.com/sveltejs/svelte
fix: improve props aliasing (#9900)
parent
0236cf87e7
commit
a9a5b11c78
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: improve props aliasing
|
@ -0,0 +1,5 @@
|
||||
<script>
|
||||
let { count: definedCount } = $props();
|
||||
</script>
|
||||
|
||||
<button on:click={() => definedCount++}>{definedCount}</button>
|
@ -0,0 +1,32 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: `
|
||||
<p>0 0 0 0</p>
|
||||
<button>0</button>
|
||||
<button>0</button>
|
||||
<button>0</button>
|
||||
<button>0</button>
|
||||
`,
|
||||
|
||||
async test({ assert, target, component }) {
|
||||
const [b1, b2, b3, b4] = target.querySelectorAll('button');
|
||||
|
||||
b1.click();
|
||||
b2.click();
|
||||
b3.click();
|
||||
b4.click();
|
||||
await Promise.resolve();
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<p>1 1 0 0</p>
|
||||
<button>1</button>
|
||||
<button>1</button>
|
||||
<button>1</button>
|
||||
<button>1</button>
|
||||
`
|
||||
);
|
||||
}
|
||||
});
|
@ -0,0 +1,15 @@
|
||||
<script>
|
||||
import Counter from './Counter.svelte';
|
||||
|
||||
let bound = $state(0);
|
||||
let bound_nested = $state({count: 0});
|
||||
let unbound = $state(0);
|
||||
let unbound_nested = $state({count: 0});
|
||||
</script>
|
||||
|
||||
<p>{bound} {bound_nested.count} {unbound} {unbound_nested.count}</p>
|
||||
|
||||
<Counter bind:count={bound} />
|
||||
<Counter bind:count={bound_nested.count} />
|
||||
<Counter count={unbound} />
|
||||
<Counter count={unbound_nested.count} />
|
Loading…
Reference in new issue