Skip to content

Commit 02a30b5

Browse files
committed
fix: mark reactions of MAYBE_DIRTY reactions too
1 parent 26e3286 commit 02a30b5

File tree

6 files changed

+63
-1
lines changed

6 files changed

+63
-1
lines changed

.changeset/sour-jars-sniff.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: mark reactions of `MAYBE_DIRTY` reactions too

packages/svelte/src/internal/client/reactivity/sources.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ function mark_reactions(signal, status) {
280280
set_signal_status(reaction, status);
281281

282282
// If the signal a) was previously clean or b) is an unowned derived, then mark it
283-
if ((flags & (CLEAN | UNOWNED)) !== 0) {
283+
if ((flags & (CLEAN | UNOWNED | MAYBE_DIRTY)) !== 0) {
284284
if ((flags & DERIVED) !== 0) {
285285
mark_reactions(/** @type {Derived} */ (reaction), MAYBE_DIRTY);
286286
} else {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<script>
2+
let {config, value = $bindable()} = $props();
3+
4+
$effect.pre(() => {
5+
config;
6+
value = {}
7+
});
8+
</script>
9+
10+
a
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<script>
2+
let {config, value = $bindable()} = $props();
3+
4+
$effect.pre(() => {
5+
config;
6+
value = {}
7+
});
8+
</script>
9+
10+
b
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { flushSync } from 'svelte';
2+
import { test } from '../../test';
3+
4+
export default test({
5+
html: '<button></button> a',
6+
async test({ assert, target }) {
7+
const btn = target.querySelector('button');
8+
flushSync(() => {
9+
btn?.click();
10+
});
11+
12+
assert.htmlEqual(target.innerHTML, `<button></button> b`);
13+
}
14+
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<script>
2+
import A from "./A.svelte";
3+
import B from "./B.svelte";
4+
5+
let schema = $state("any");
6+
let value = $state({});
7+
8+
let config = $derived.by(() => {
9+
value;
10+
return schema;
11+
});
12+
13+
let Thing = $derived.by(() => {
14+
console.log("comp", config);
15+
return config === "any" ? A : B;
16+
});
17+
</script>
18+
19+
<button onclick={()=>{
20+
schema = "one";
21+
}}></button>
22+
23+
<Thing {config} bind:value/>

0 commit comments

Comments
 (0)