mirror of https://github.com/sveltejs/svelte
fix: capture the correct event names when spreading attributes (#11783)
fixes #11777 We need to scope the `key` variable because it may be captured in a closurepull/11795/head
parent
ee9d5ef850
commit
4fef0eb08f
@ -0,0 +1,5 @@
|
||||
---
|
||||
"svelte": patch
|
||||
---
|
||||
|
||||
fix: capture the correct event names when spreading attributes
|
@ -0,0 +1,16 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
test({ assert, target }) {
|
||||
const div = target.querySelector('div');
|
||||
|
||||
div?.dispatchEvent(new Event('b'));
|
||||
flushSync();
|
||||
assert.htmlEqual(target.innerHTML, '<div>b</div>');
|
||||
|
||||
div?.dispatchEvent(new Event('a'));
|
||||
flushSync();
|
||||
assert.htmlEqual(target.innerHTML, '<div>a</div>');
|
||||
}
|
||||
});
|
@ -0,0 +1,8 @@
|
||||
<script lang="ts">
|
||||
const props = {};
|
||||
let changed = $state('');
|
||||
</script>
|
||||
|
||||
<div {...props} ona={() => (changed = 'a')} onb={() => (changed = 'b')}>
|
||||
{changed}
|
||||
</div>
|
Loading…
Reference in new issue