fix: when an unowned derived is tracked again, remove unowned flag

pull/15255/head
Dominic Gannaway 2 years ago
parent c4d4349d0a
commit e3d69b5372

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: when an unowned derived is tracked again, remove unowned flag

@ -184,19 +184,29 @@ export function check_dirtiness(reaction) {
// If we are working with a disconnected or an unowned signal that is now connected (due to an active effect)
// then we need to re-connect the reaction to the dependency
if (is_disconnected || is_unowned_connected) {
var derived = /** @type {Derived} */ (reaction);
for (i = 0; i < length; i++) {
dependency = dependencies[i];
// We always re-add all reactions (even duplicates) if the derived was
// previously disconnected, however we don't if it was unowned as we
// de-duplicate dependencies in that case
if (is_disconnected || !dependency?.reactions?.includes(reaction)) {
(dependency.reactions ??= []).push(reaction);
if (is_disconnected || !dependency?.reactions?.includes(derived)) {
(dependency.reactions ??= []).push(derived);
}
}
if (is_disconnected) {
reaction.f ^= DISCONNECTED;
derived.f ^= DISCONNECTED;
}
var parent = derived.parent;
if (is_unowned_connected && parent !== null && (parent.f & UNOWNED) === 0) {
// If the derived is owned by another derived then mark it as owned agaub
// as the derived value might have been referenced in a different context
// and now has a reacive context managing it
derived.f ^= UNOWNED;
}
}
@ -409,6 +419,10 @@ export function update_reaction(reaction) {
(flags & UNOWNED) !== 0 &&
(!is_flushing_effect || previous_reaction === null || previous_untracking);
if (skip_reaction) {
// debugger
}
derived_sources = null;
set_component_context(reaction.ctx);
untracking = false;

Loading…
Cancel
Save