mirror of https://github.com/sveltejs/svelte
fix: make `$state` component exports settable (#12345)
* fix: make `$state` component exports settable fixes #11983 * failing test * fix --------- Co-authored-by: Rich Harris <rich.harris@vercel.com>pull/12353/head
parent
14cbb65d85
commit
e8c3729fc9
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: make `$state` component exports settable
|
@ -0,0 +1,12 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
test({ assert, target }) {
|
||||
assert.htmlEqual(target.innerHTML, `0 0 <button>0 / 0</button>`);
|
||||
const btn = target.querySelector('button');
|
||||
|
||||
flushSync(() => btn?.click());
|
||||
assert.htmlEqual(target.innerHTML, '1 2 <button>1 / 2</button>');
|
||||
}
|
||||
});
|
@ -0,0 +1,7 @@
|
||||
<script>
|
||||
import Sub from './sub.svelte';
|
||||
let sub = $state();
|
||||
</script>
|
||||
|
||||
<Sub bind:this={sub} />
|
||||
<button on:click={() => sub.count++}>{sub?.count} / {sub?.doubled}</button>
|
@ -0,0 +1,9 @@
|
||||
<script>
|
||||
let count = $state(0);
|
||||
let doubled = $derived(count * 2);
|
||||
|
||||
export { count, doubled };
|
||||
</script>
|
||||
|
||||
{count}
|
||||
{doubled}
|
Loading…
Reference in new issue