mirror of https://github.com/sveltejs/svelte
fix: dynamic event delegation for stateful call expressions (#12549)
parent
55400fd16c
commit
90d6f573e3
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: dynamic event delegation for stateful call expressions
|
@ -0,0 +1,24 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test, ok } from '../../test';
|
||||
|
||||
export default test({
|
||||
mode: ['client'],
|
||||
async test({ assert, target, logs }) {
|
||||
const [btn1, btn2, btn3] = target.querySelectorAll('button');
|
||||
|
||||
flushSync(() => {
|
||||
btn1.click();
|
||||
btn2.click();
|
||||
});
|
||||
|
||||
assert.deepEqual(logs, ['AA', 'AB']);
|
||||
|
||||
flushSync(() => {
|
||||
btn3.click();
|
||||
btn1.click();
|
||||
btn2.click();
|
||||
});
|
||||
|
||||
assert.deepEqual(logs, ['AA', 'AB', 'BA', 'BB']);
|
||||
}
|
||||
});
|
@ -0,0 +1,15 @@
|
||||
<script>
|
||||
let hof = $state((name) => () => console.log('A' + name));
|
||||
const member = $derived({
|
||||
hof
|
||||
});
|
||||
function change() {
|
||||
hof = (name) => () => console.log('B' + name);
|
||||
}
|
||||
</script>
|
||||
|
||||
<button onclick={hof('A')}>A</button>
|
||||
<button onclick={member.hof('B')}>B</button>
|
||||
|
||||
<br />
|
||||
<button onclick={change}>change</button>
|
Loading…
Reference in new issue