mirror of https://github.com/sveltejs/svelte
parent
4c4f18b24c
commit
1f973b1770
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: remove spreaded event handlers when they become nullish
|
@ -0,0 +1,32 @@
|
||||
import { ok, test } from '../../test';
|
||||
import { flushSync } from 'svelte';
|
||||
|
||||
export default test({
|
||||
async test({ assert, target, instance }) {
|
||||
const p = target.querySelector('p');
|
||||
const btn = target.querySelector('button');
|
||||
const input = target.querySelector('input');
|
||||
ok(p);
|
||||
|
||||
flushSync(() => {
|
||||
btn?.click();
|
||||
});
|
||||
assert.equal(p.innerHTML, '1');
|
||||
|
||||
flushSync(() => {
|
||||
input?.click();
|
||||
});
|
||||
flushSync(() => {
|
||||
btn?.click();
|
||||
});
|
||||
assert.equal(p.innerHTML, '1');
|
||||
|
||||
flushSync(() => {
|
||||
input?.click();
|
||||
});
|
||||
flushSync(() => {
|
||||
btn?.click();
|
||||
});
|
||||
assert.equal(p.innerHTML, '2');
|
||||
}
|
||||
});
|
@ -0,0 +1,12 @@
|
||||
<script>
|
||||
let checked = $state(true)
|
||||
let count = $state(0)
|
||||
|
||||
const onclick = $derived(checked ? (() => { count++ }) : undefined)
|
||||
</script>
|
||||
|
||||
<p>
|
||||
{count}
|
||||
</p>
|
||||
<input type="checkbox" bind:checked />
|
||||
<button {...{onclick}}></button>
|
Loading…
Reference in new issue