chore: remove first_batch?.next checks for reads outside reactivity

Neither the check in internal_set nor the one in update_derived is needed for any test.
async-another-try-pt-1-prune
Rich Harris 10 hours ago
parent 579224846e
commit 927e5baff2
No known key found for this signature in database

@ -44,7 +44,7 @@ import { get_error } from '../../shared/dev.js';
import { async_mode_flag, tracing_mode_flag } from '../../flags/index.js';
import { component_context } from '../context.js';
import { UNINITIALIZED } from '../../../constants.js';
import { batch_values, current_batch, first_batch, previous_batch } from './batch.js';
import { batch_values, current_batch, previous_batch } from './batch.js';
import { increment_pending, unset_context } from './async.js';
import { deferred, includes, noop } from '../../shared/utils.js';
import { set_signal_status, update_derived_status } from './status.js';
@ -445,15 +445,11 @@ export function update_derived(derived) {
// During time travelling, keep stale results batch-local. A result computed
// from the latest inputs can be marked globally clean, even if it is unchanged
// and its write version therefore remains below its dependencies' versions.
if (
batch_values !== null ||
// "read outside of reactivity", e.g. in an event handler
(!current_batch && first_batch?.next)
) {
if (batch_values !== null) {
// only cache the value if we're in a tracking context, otherwise we won't
// clear the cache in `mark_reactions` when dependencies are updated
if (effect_tracking() || current_batch?.is_fork) {
batch_values?.set(derived, value);
batch_values.set(derived, value);
}
var is_latest_value =
value === derived.v &&

@ -36,8 +36,7 @@ import {
batch_values,
eager_block_effects,
schedule_effect,
legacy_updates,
first_batch
legacy_updates
} from './batch.js';
import { proxy } from '../proxy.js';
import { execute_derived } from './deriveds.js';
@ -206,11 +205,7 @@ export function internal_set(source, value, updated_during_traversal = null) {
// During time traveling we don't want to reset the status so that
// traversal of the graph in the other batches still happens
if (
batch_values === null &&
// could also be "read outside of reactivity", e.g. in an event handler
!first_batch?.next
) {
if (batch_values === null) {
update_derived_status(derived);
}
}

Loading…
Cancel
Save