mirror of https://github.com/sveltejs/svelte
fix: ensure spread events are always added (#11535)
In edge cases it may happen that set_attributes is re-run before the effect is executed. In that case the render effect which initiates this re-run will destroy the inner effect and it will never run. But because next and prev may have the same keys, the event would not get added again and it would get lost. We prevent this by using a root effect. The added test case doesn't fail for some reason without this fix, but it does fail when you test it out manually, so I still added it. Found through https://github.com/sveltejs/svelte/issues/10359#issuecomment-2101167524pull/11544/head
parent
31f8fea22d
commit
641e411cf1
@ -0,0 +1,5 @@
|
||||
---
|
||||
"svelte": patch
|
||||
---
|
||||
|
||||
fix: ensure spread events are added even when rerunning spread immediately
|
@ -0,0 +1,15 @@
|
||||
import { test, ok } from '../../test';
|
||||
|
||||
export default test({
|
||||
mode: ['client'],
|
||||
|
||||
async test({ assert, logs, target }) {
|
||||
const input = target.querySelector('input');
|
||||
ok(input);
|
||||
|
||||
input.value = 'foo';
|
||||
await input.dispatchEvent(new Event('input'));
|
||||
|
||||
assert.deepEqual(logs, ['hi']);
|
||||
}
|
||||
});
|
@ -0,0 +1,7 @@
|
||||
<script>
|
||||
let rest = $state(undefined);
|
||||
</script>
|
||||
|
||||
<input {...rest} oninput={() => console.log('hi')}>
|
||||
<!-- after input and inside template so that attribute spread reruns immediately -->
|
||||
{!rest ? (rest = {}) : false}
|
Loading…
Reference in new issue