mirror of https://github.com/sveltejs/svelte
fix: improve derived rune destructuring support (#10665)
parent
61e7442ccf
commit
710f73f9cf
@ -0,0 +1,5 @@
|
||||
---
|
||||
"svelte": patch
|
||||
---
|
||||
|
||||
fix: improve derived rune destructuring support
|
@ -0,0 +1,14 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
async test({ assert, target }) {
|
||||
const btn = target.querySelector('button');
|
||||
await btn?.click();
|
||||
|
||||
assert.htmlEqual(target.innerHTML, `<button>1 1 1</button>`);
|
||||
|
||||
await btn?.click();
|
||||
|
||||
assert.htmlEqual(target.innerHTML, `<button>2 2 2</button>`);
|
||||
}
|
||||
});
|
@ -0,0 +1,23 @@
|
||||
|
||||
<script>
|
||||
function get_values() {
|
||||
let a = $state(0);
|
||||
let b = $state(0);
|
||||
let c = $state(0);
|
||||
|
||||
return {
|
||||
get a() { return a },
|
||||
get b() { return b },
|
||||
get c() { return c },
|
||||
increment() {
|
||||
a++;
|
||||
b++;
|
||||
c++;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const { a, b, c, increment } = $derived(get_values());
|
||||
</script>
|
||||
|
||||
<button onclick={increment}>{a} {b} {c}</button>
|
Loading…
Reference in new issue