pull/16625/head
Rich Harris 3 weeks ago
parent 2e02868ef1
commit 8d710765c2

@ -133,29 +133,31 @@ function create_effect(type, fn, sync, push = true) {
schedule_effect(effect); schedule_effect(effect);
} }
// if an effect has no dependencies, no DOM and no teardown function, if (push) {
// don't bother adding it to the effect tree // if an effect has no dependencies, no DOM and no teardown function,
var inert = // don't bother adding it to the effect tree
sync && var inert =
effect.deps === null && sync &&
effect.first === null && effect.deps === null &&
effect.nodes_start === null && effect.first === null &&
effect.teardown === null && effect.nodes_start === null &&
(effect.f & EFFECT_PRESERVED) === 0; effect.teardown === null &&
(effect.f & EFFECT_PRESERVED) === 0;
if (!inert && push) {
if (parent !== null) { if (!inert) {
push_effect(effect, parent); if (parent !== null) {
} push_effect(effect, parent);
}
// if we're in a derived, add the effect there too // if we're in a derived, add the effect there too
if ( if (
active_reaction !== null && active_reaction !== null &&
(active_reaction.f & DERIVED) !== 0 && (active_reaction.f & DERIVED) !== 0 &&
(type & ROOT_EFFECT) === 0 (type & ROOT_EFFECT) === 0
) { ) {
var derived = /** @type {Derived} */ (active_reaction); var derived = /** @type {Derived} */ (active_reaction);
(derived.effects ??= []).push(effect); (derived.effects ??= []).push(effect);
}
} }
} }

Loading…
Cancel
Save