Skip to content

Commit b6be14a

Browse files
committed
fix
1 parent dfaf0d2 commit b6be14a

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

packages/svelte/src/internal/client/dom/elements/events.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,27 @@ export function replay_events(dom) {
5656
* @param {AddEventListenerOptions} [options]
5757
*/
5858
export function create_event(event_name, dom, handler, options = {}) {
59+
var boundary_effect = (active_effect !== null && get_boundary(active_effect)) ?? null;
5960
/**
6061
* @this {EventTarget}
6162
*/
6263
function target_handler(/** @type {Event} */ event) {
63-
if (!options.capture) {
64-
// Only call in the bubble phase, else delegated events would be called before the capturing events
65-
handle_event_propagation.call(dom, event);
66-
}
67-
if (!event.cancelBubble) {
68-
return without_reactive_context(() => {
69-
return handler?.call(this, event);
70-
});
64+
var previous_boundary_effect = event_boundary_effect;
65+
try {
66+
if (boundary_effect !== null) {
67+
set_event_boundary_effect(boundary_effect);
68+
}
69+
if (!options.capture) {
70+
// Only call in the bubble phase, else delegated events would be called before the capturing events
71+
handle_event_propagation.call(dom, event);
72+
}
73+
if (!event.cancelBubble) {
74+
return without_reactive_context(() => {
75+
return handler?.call(this, event);
76+
});
77+
}
78+
} finally {
79+
set_event_boundary_effect(previous_boundary_effect)
7180
}
7281
}
7382

packages/svelte/src/internal/client/reactivity/sources.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ export function mark_reactions(signal, status, source) {
289289
// If the signal a) was previously clean or b) is an unowned derived, then mark it
290290
if ((flags & (CLEAN | UNOWNED)) !== 0) {
291291
if ((flags & DERIVED) !== 0) {
292-
mark_reactions(/** @type {Derived} */ (reaction), MAYBE_DIRTY);
292+
mark_reactions(/** @type {Derived} */ (reaction), MAYBE_DIRTY, source);
293293
} else {
294294
schedule_effect(/** @type {Effect} */ (reaction), source);
295295
}

0 commit comments

Comments
 (0)