Skip to content

Commit c915e68

Browse files
committed
Add comments
1 parent 0fdf121 commit c915e68

File tree

2 files changed

+12
-12
lines changed
  • packages/svelte

2 files changed

+12
-12
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -897,14 +897,16 @@ function mark_signal_consumers(signal, to_status, force_schedule) {
897897
const flags = consumer.flags;
898898
const unowned = (flags & UNOWNED) !== 0;
899899
const dirty = (flags & DIRTY) !== 0;
900-
if (
901-
(dirty && !unowned) ||
902-
(!runes && consumer === current_effect) ||
903-
(!force_schedule && consumer === current_effect)
904-
) {
900+
// We skip any effects that are already dirty (but not unowned). Additionally, we also
901+
// skip if the consumer is the same as the current effect (except if we're not in runes or we
902+
// are in force schedule mode).
903+
if ((dirty && !unowned) || ((!force_schedule || !runes) && consumer === current_effect)) {
905904
continue;
906905
}
907906
set_signal_status(consumer, to_status);
907+
// If the signal is not clean, then skip over it – with the exception of unowned signals that
908+
// are already dirty. Unowned signals might be dirty because they are not captured as part of an
909+
// effect.
908910
if ((flags & CLEAN) !== 0 || (dirty && unowned)) {
909911
if ((consumer.flags & IS_EFFECT) !== 0) {
910912
schedule_effect(/** @type {import('./types.js').EffectSignal} */ (consumer), false);

packages/svelte/tests/runtime-runes/samples/class-state-derived-unowned/main.svelte

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<script context="module">
22
class SomeLogic {
3-
someValue = $state(0);
4-
isAboveThree = $derived(this.someValue > 3)
5-
trigger(){
6-
this.someValue++;
3+
someValue = $state(0);
4+
isAboveThree = $derived(this.someValue > 3);
5+
trigger() {
6+
this.someValue++;
7+
}
78
}
8-
}
99
1010
const someLogic = new SomeLogic();
1111
</script>
@@ -23,11 +23,9 @@
2323
log.push(someLogic.someValue);
2424
});
2525
$effect(() => {
26-
// Does not trigger
2726
log.push('class trigger ' + someLogic.isAboveThree)
2827
});
2928
$effect(() => {
30-
// Does Triggers
3129
log.push('local trigger ' + localDerived)
3230
});
3331

0 commit comments

Comments
 (0)