fix: fire delegated events on target even it was disabled in the meantime (#15319)

They DOM could've been updated already by the time the event bubbling logic is reached, so the target element itself could not be notified of the event because it is marked as disabled. But the target could not have been disabled because it emits the event in the first place, so we emit regardless.

No test because not reproducible in jsdom environment.

Fixes #15256
pull/15304/head
Simon H 7 months ago committed by GitHub
parent 0d5d9ab760
commit 9091e7e930
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: fire delegated events on target even it was disabled in the meantime

@ -237,7 +237,13 @@ export function handle_event_propagation(event) {
// @ts-expect-error
var delegated = current_target['__' + event_name];
if (delegated !== undefined && !(/** @type {any} */ (current_target).disabled)) {
if (
delegated !== undefined &&
(!(/** @type {any} */ (current_target).disabled) ||
// DOM could've been updated already by the time this is reached, so we check this as well
// -> the target could not have been disabled because it emits the event in the first place
event.target === current_target)
) {
if (is_array(delegated)) {
var [fn, ...data] = delegated;
fn.apply(current_target, [event, ...data]);

Loading…
Cancel
Save