mirror of https://github.com/sveltejs/svelte
fix: keep spread non-delegated event handlers up to date (#16180)
* fix: keep spread non-delegated event handlers up to date #15961 introduced a regression where non-delegated events that were spread and updated were not getting updated. This fixes that by ensuring prev is actually updated to the most recent value * fixpull/16195/head
parent
838f881550
commit
a5f500e7c0
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: keep spread non-delegated event handlers up to date
|
@ -0,0 +1,18 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
test({ assert, target }) {
|
||||
const [change, increment] = target.querySelectorAll('button');
|
||||
|
||||
increment.click();
|
||||
flushSync();
|
||||
assert.htmlEqual(target.innerHTML, '<button>change handlers</button><button>1 / 1</button>');
|
||||
|
||||
change.click();
|
||||
flushSync();
|
||||
increment.click();
|
||||
flushSync();
|
||||
assert.htmlEqual(target.innerHTML, '<button>change handlers</button><button>3 / 3</button>');
|
||||
}
|
||||
});
|
@ -0,0 +1,27 @@
|
||||
<script>
|
||||
let delegated = $state(0);
|
||||
let non_delegated = $state(0);
|
||||
let attrs = $state({
|
||||
onclick: () => {
|
||||
delegated += 1;
|
||||
},
|
||||
onclickcapture: () => {
|
||||
non_delegated += 1;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<button
|
||||
onclick={() =>
|
||||
(attrs = {
|
||||
onclick: () => {
|
||||
delegated += 2;
|
||||
},
|
||||
onclickcapture: () => {
|
||||
non_delegated += 2;
|
||||
}
|
||||
})}
|
||||
>
|
||||
change handlers
|
||||
</button>
|
||||
<button {...attrs}>{delegated} / {non_delegated}</button>
|
Loading…
Reference in new issue