fix: mark reactions of `MAYBE_DIRTY` reactions too

derived-reactions-maybe-dirty-marked
paoloricciuti 3 months ago
parent 26e3286899
commit 02a30b5602

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: mark reactions of `MAYBE_DIRTY` reactions too

@ -280,7 +280,7 @@ function mark_reactions(signal, status) {
set_signal_status(reaction, status); set_signal_status(reaction, status);
// If the signal a) was previously clean or b) is an unowned derived, then mark it // If the signal a) was previously clean or b) is an unowned derived, then mark it
if ((flags & (CLEAN | UNOWNED)) !== 0) { if ((flags & (CLEAN | UNOWNED | MAYBE_DIRTY)) !== 0) {
if ((flags & DERIVED) !== 0) { if ((flags & DERIVED) !== 0) {
mark_reactions(/** @type {Derived} */ (reaction), MAYBE_DIRTY); mark_reactions(/** @type {Derived} */ (reaction), MAYBE_DIRTY);
} else { } else {

@ -0,0 +1,10 @@
<script>
let {config, value = $bindable()} = $props();
$effect.pre(() => {
config;
value = {}
});
</script>
a

@ -0,0 +1,10 @@
<script>
let {config, value = $bindable()} = $props();
$effect.pre(() => {
config;
value = {}
});
</script>
b

@ -0,0 +1,14 @@
import { flushSync } from 'svelte';
import { test } from '../../test';
export default test({
html: '<button></button> a',
async test({ assert, target }) {
const btn = target.querySelector('button');
flushSync(() => {
btn?.click();
});
assert.htmlEqual(target.innerHTML, `<button></button> b`);
}
});

@ -0,0 +1,23 @@
<script>
import A from "./A.svelte";
import B from "./B.svelte";
let schema = $state("any");
let value = $state({});
let config = $derived.by(() => {
value;
return schema;
});
let Thing = $derived.by(() => {
console.log("comp", config);
return config === "any" ? A : B;
});
</script>
<button onclick={()=>{
schema = "one";
}}></button>
<Thing {config} bind:value/>
Loading…
Cancel
Save