mirror of https://github.com/sveltejs/svelte
fix: correctly reference destructured derived binding in event handler (#10333)
parent
6145be5c69
commit
4d0d0a3a9d
@ -0,0 +1,5 @@
|
||||
---
|
||||
"svelte": patch
|
||||
---
|
||||
|
||||
fix: correctly reference destructured derived binding in event handler
|
@ -0,0 +1,15 @@
|
||||
import { test } from '../../test';
|
||||
import { log } from './log.js';
|
||||
|
||||
export default test({
|
||||
before_test() {
|
||||
log.length = 0;
|
||||
},
|
||||
|
||||
async test({ assert, target, window }) {
|
||||
const btn = target.querySelector('button');
|
||||
await btn?.click();
|
||||
|
||||
assert.deepEqual(log, ['works!']);
|
||||
}
|
||||
});
|
@ -0,0 +1,2 @@
|
||||
/** @type {any[]} */
|
||||
export const log = [];
|
@ -0,0 +1,15 @@
|
||||
<script>
|
||||
import { log } from './log.js';
|
||||
|
||||
let structured = $state({
|
||||
handler() {
|
||||
log.push('works!')
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if structured}
|
||||
{@const { handler } = structured}
|
||||
|
||||
<button onclick={() => handler()}>click me</button>
|
||||
{/if}
|
Loading…
Reference in new issue