mirror of https://github.com/sveltejs/svelte
fix: properly transform destructured `$derived.by` declarations (#12984)
fixes #12983pull/12988/head
parent
f1a1a08a74
commit
b4382e422d
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: properly transform destructured `$derived.by` declarations
|
@ -0,0 +1,13 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: '<button>clicks: 0</button>',
|
||||
|
||||
test({ assert, target }) {
|
||||
const btn = target.querySelector('button');
|
||||
|
||||
flushSync(() => btn?.click());
|
||||
assert.htmlEqual(target.innerHTML, `<button>clicks: 1</button>`);
|
||||
}
|
||||
});
|
@ -0,0 +1,8 @@
|
||||
<script>
|
||||
let count = $state(0);
|
||||
let fn = () => ({ n: count });
|
||||
|
||||
let { n } = $derived.by(fn);
|
||||
</script>
|
||||
|
||||
<button onclick={() => (count += 1)}>clicks: {n}</button>
|
Loading…
Reference in new issue