pull/12350/head
Rich Harris 2 years ago
parent 5bb2cf91e4
commit a61b39eb30

@ -1,12 +1,4 @@
import {
CLEAN,
DERIVED,
DESTROYED,
DIRTY,
DISCONNECTED,
MAYBE_DIRTY,
UNOWNED
} from '../constants.js';
import { CLEAN, DERIVED, DESTROYED, DIRTY, MAYBE_DIRTY, UNOWNED } from '../constants.js';
import {
current_reaction,
current_effect,
@ -129,24 +121,3 @@ export function destroy_derived(signal) {
signal.fn =
null;
}
/**
* @param {import('#client').Derived} derived
*/
export function reconnect_derived(derived) {
var deps = derived.deps;
if (deps !== null) {
for (var i = 0; i < deps.length; i++) {
var dep = deps[i];
var reactions = dep.reactions;
if (reactions === null) {
dep.reactions = [derived];
} else if (!reactions.includes(derived)) {
reactions.push(derived);
}
}
}
derived.f ^= DISCONNECTED;
}

@ -34,7 +34,7 @@ import {
import { flush_tasks } from './dom/task.js';
import { add_owner } from './dev/ownership.js';
import { mutate, set, source } from './reactivity/sources.js';
import { reconnect_derived, update_derived } from './reactivity/deriveds.js';
import { update_derived } from './reactivity/deriveds.js';
import * as e from './errors.js';
import { lifecycle_outside_component } from '../shared/errors.js';
@ -172,6 +172,14 @@ export function check_dirtiness(reaction) {
if (dependencies !== null) {
var is_unowned = (flags & UNOWNED) !== 0;
if ((flags & DISCONNECTED) !== 0) {
for (var i = 0; i < dependencies.length; i++) {
(dependencies[i].reactions ??= []).push(reaction);
}
reaction.f ^= DISCONNECTED;
}
for (var i = 0; i < dependencies.length; i++) {
var dependency = dependencies[i];
@ -193,10 +201,6 @@ export function check_dirtiness(reaction) {
}
}
}
if ((flags & DISCONNECTED) !== 0) {
reconnect_derived(/** @type {import('#client').Derived} */ (reaction));
}
}
set_signal_status(reaction, CLEAN);
@ -774,10 +778,6 @@ export function get(signal) {
if (check_dirtiness(derived)) {
update_derived(derived);
}
if ((flags & DISCONNECTED) !== 0) {
reconnect_derived(derived);
}
}
return signal.v;

Loading…
Cancel
Save