diff --git a/.changeset/seven-news-live.md b/.changeset/seven-news-live.md new file mode 100644 index 0000000000..cfe6f3bc33 --- /dev/null +++ b/.changeset/seven-news-live.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: ensure event currentTarget is reset after propagation logic diff --git a/packages/svelte/src/internal/client/dom/elements/events.js b/packages/svelte/src/internal/client/dom/elements/events.js index fbea9d4b6d..efbc568165 100644 --- a/packages/svelte/src/internal/client/dom/elements/events.js +++ b/packages/svelte/src/internal/client/dom/elements/events.js @@ -3,7 +3,6 @@ import { teardown } from '../../reactivity/effects.js'; import { define_property, is_array } from '../../../shared/utils.js'; import { hydrating } from '../hydration.js'; import { queue_micro_task } from '../task.js'; -import { dev_current_component_function } from '../../runtime.js'; import { FILENAME } from '../../../../constants.js'; import * as w from '../../warnings.js'; @@ -273,8 +272,8 @@ export function handle_event_propagation(event) { } finally { // @ts-expect-error is used above event.__root = handler_element; - // @ts-expect-error is used above - current_target = handler_element; + // @ts-ignore remove proxy on currentTarget + delete event.currentTarget; } } diff --git a/packages/svelte/tests/runtime-runes/samples/event-attribute-delegation-8/_config.js b/packages/svelte/tests/runtime-runes/samples/event-attribute-delegation-8/_config.js new file mode 100644 index 0000000000..46ba6ca54c --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/event-attribute-delegation-8/_config.js @@ -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]); + } +}); diff --git a/packages/svelte/tests/runtime-runes/samples/event-attribute-delegation-8/main.svelte b/packages/svelte/tests/runtime-runes/samples/event-attribute-delegation-8/main.svelte new file mode 100644 index 0000000000..e0d7821143 --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/event-attribute-delegation-8/main.svelte @@ -0,0 +1,22 @@ + + +