mirror of https://github.com/sveltejs/svelte
fix: ensure event currentTarget is reset after propagation logic (#13042)
* fix: ensure event currentTarget is reset after propgation logic * fix: ensure event currentTarget is reset after propgation logicpull/13057/head
parent
e860547cb6
commit
9cb9692aea
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: ensure event currentTarget is reset after propagation logic
|
@ -0,0 +1,11 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
async test({ assert, target, logs }) {
|
||||
const btn = target.querySelector('button');
|
||||
|
||||
btn?.click();
|
||||
await Promise.resolve();
|
||||
assert.deepEqual(logs, ['#app', true, 'document', true]);
|
||||
}
|
||||
});
|
@ -0,0 +1,22 @@
|
||||
<script>
|
||||
$effect(() => {
|
||||
const doc_listener = (e) => {
|
||||
console.log('document', e.currentTarget === document);
|
||||
}
|
||||
|
||||
document.addEventListener('click', doc_listener);
|
||||
document.getElementById('app')?.addEventListener('click', (e) => {
|
||||
console.log('#app', e.currentTarget === document.getElementById('app'));
|
||||
});
|
||||
|
||||
return () => {
|
||||
document.removeEventListener('click', doc_listener);
|
||||
};
|
||||
});
|
||||
|
||||
function onclick() {}
|
||||
</script>
|
||||
|
||||
<div id="app">
|
||||
<button {onclick}>click me</button>
|
||||
</div>
|
Loading…
Reference in new issue