-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ensure derived is detected as dirty correctly
Deriveds where under certain conditions not detected as dirty correctly. The reason is that a transitive check_dirtiness call could update the flag of a derived, even if the condition doesn't ulimately result to true. That's why the check for "is now dirty" needs to be moved out of the inner if block. Fixes #11481 This may also fix a yet undetected overfiring bug in the "is unowned" case because the previous inner "is now dirty?" check didn't take unowned into account.
- Loading branch information
1 parent
f2f71ae
commit fc43cff
Showing
4 changed files
with
32 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"svelte": patch | ||
--- | ||
|
||
fix: ensure derived is detected as dirty correctly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
packages/svelte/tests/runtime-runes/samples/derived-cascade/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
html: `<button>00</button>`, | ||
|
||
async test({ assert, target }) { | ||
const btn = target.querySelector('button'); | ||
await btn?.click(); | ||
|
||
assert.htmlEqual(target.innerHTML, `<button>01</button>`); | ||
} | ||
}); |
12 changes: 12 additions & 0 deletions
12
packages/svelte/tests/runtime-runes/samples/derived-cascade/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<script> | ||
let shouldShow01 = $state(false); | ||
let der1 = $derived(shouldShow01) | ||
// der2 must depend on der1 and its output shouldn't change | ||
let der2 = $derived(typeof der1 === "string"); | ||
let der3 = $derived(der2 ? "1" : "0"); | ||
// der3 must be read before der1 | ||
let der4 = $derived(der3 + (der1 ? "1" : "0")); | ||
</script> | ||
|
||
<button onclick={() => (shouldShow01 = true)}>{der4}</button> |