Skip to content

Commit f719ea3

Browse files
committed
fix issue
1 parent 4a556c9 commit f719ea3

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ export function update_derived(derived, force_schedule) {
117117
*/
118118
export function destroy_derived(signal) {
119119
destroy_derived_children(signal);
120+
destroy_effect_children(signal);
120121
remove_reactions(signal, 0);
121122
set_signal_status(signal, DESTROYED);
122123

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,16 @@ function create_effect(type, fn, sync) {
9393
}
9494

9595
if (current_reaction !== null && !is_root) {
96-
if ((current_reaction.f & (DERIVED | UNOWNED)) === (DERIVED | UNOWNED)) {
97-
e.effect_in_unowned_derived();
96+
var flags = current_reaction.f;
97+
if ((flags & DERIVED) !== 0) {
98+
if ((flags & UNOWNED) !== 0) {
99+
e.effect_in_unowned_derived();
100+
}
101+
// If we are inside a derived, then we also need to attach the
102+
// effect to the parent effect too.
103+
if (current_effect !== null) {
104+
push_effect(effect, current_effect);
105+
}
98106
}
99107

100108
push_effect(effect, current_reaction);

0 commit comments

Comments
 (0)