Skip to content

Commit 49013d7

Browse files
committed
fix: ensure $inspect.trace indicated dirty traced deps correctly
1 parent 1d773ef commit 49013d7

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

packages/svelte/src/internal/client/runtime.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,22 @@ export function update_effect(effect) {
528528
effect.teardown = typeof teardown === 'function' ? teardown : null;
529529
effect.version = current_version;
530530

531+
var version = current_version;
532+
var deps = effect.deps;
533+
534+
// In DEV, we need to handle a case where $inspect.trace() might
535+
// incorrectly state a source dependency has not changed when it has.
536+
// That's beacuse that source was changed by the same effect, causing
537+
// the versions to match. We can avoid this by incrementing the version
538+
if (DEV && (effect.f & DIRTY) !== 0 && deps !== null) {
539+
for (let i = 0; i < deps.length; i++) {
540+
var dep = deps[i];
541+
if ((dep.f & DERIVED) === 0 && dep.version === version) {
542+
dep.version = increment_version();
543+
}
544+
}
545+
}
546+
531547
if (DEV) {
532548
dev_effect_stack.push(effect);
533549
}

0 commit comments

Comments
 (0)