pull/10760/head
Rich Harris 2 years ago
parent e4c4cd153a
commit 497277174f

@ -30,8 +30,6 @@ import { add_owner } from './dev/ownership.js';
import { mutate, set, source } from './reactivity/sources.js'; import { mutate, set, source } from './reactivity/sources.js';
import { destroy_derived } from './reactivity/deriveds.js'; import { destroy_derived } from './reactivity/deriveds.js';
const IS_EFFECT = EFFECT | PRE_EFFECT | RENDER_EFFECT;
const FLUSH_MICROTASK = 0; const FLUSH_MICROTASK = 0;
const FLUSH_SYNC = 1; const FLUSH_SYNC = 1;
@ -852,36 +850,40 @@ export function mark_subtree_inert(signal, inert, visited_blocks = new Set()) {
* @returns {void} * @returns {void}
*/ */
export function mark_reactions(signal, to_status, force_schedule) { export function mark_reactions(signal, to_status, force_schedule) {
const runes = is_runes(); var reactions = signal.reactions;
const reactions = signal.reactions; if (reactions === null) return;
if (reactions !== null) {
const length = reactions.length; var runes = is_runes();
let i; var length = reactions.length;
for (i = 0; i < length; i++) {
const reaction = reactions[i]; for (var i = 0; i < length; i++) {
const flags = reaction.f; var reaction = reactions[i];
const unowned = (flags & UNOWNED) !== 0;
// We skip any effects that are already dirty (but not unowned). Additionally, we also // We skip any effects that are already dirty (but not unowned). Additionally, we also
// skip if the reaction is the same as the current effect (except if we're not in runes or we // skip if the reaction is the same as the current effect (except if we're not in runes or we
// are in force schedule mode). // are in force schedule mode).
if ((!force_schedule || !runes) && reaction === current_effect) { if ((!force_schedule || !runes) && reaction === current_effect) {
continue; continue;
} }
set_signal_status(reaction, to_status);
// If the signal is not clean, then skip over it with the exception of unowned signals that var flags = reaction.f;
// are already maybe dirty. Unowned signals might be dirty because they are not captured as part of an set_signal_status(reaction, to_status);
// effect.
const maybe_dirty = (flags & MAYBE_DIRTY) !== 0; // If the signal is not clean, then skip over it with the exception of unowned signals that
if ((flags & CLEAN) !== 0 || (maybe_dirty && unowned)) { // are already maybe dirty. Unowned signals might be dirty because they are not captured as part of an
if ((reaction.f & IS_EFFECT) !== 0) { // effect.
schedule_effect(/** @type {import('#client').Effect} */ (reaction), false); var maybe_dirty = (flags & MAYBE_DIRTY) !== 0;
} else { var unowned = (flags & UNOWNED) !== 0;
mark_reactions(
/** @type {import('#client').Derived} */ (reaction), if ((flags & CLEAN) !== 0 || (maybe_dirty && unowned)) {
MAYBE_DIRTY, if ((reaction.f & DERIVED) !== 0) {
force_schedule mark_reactions(
); /** @type {import('#client').Derived} */ (reaction),
} MAYBE_DIRTY,
force_schedule
);
} else {
schedule_effect(/** @type {import('#client').Effect} */ (reaction), false);
} }
} }
} }

Loading…
Cancel
Save