mirror of https://github.com/sveltejs/svelte
fix: allow `$derived(await ...)` in disconnected effect roots (#18273)
If `$effect.root` is created outside the component tree, the boundary property is null Fixes #18188pull/18087/merge
parent
f023e8d7c8
commit
fe9ab936b6
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: allow `$derived(await ...)` in disconnected effect roots
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
// Test that an async derived inside an $effect.root not connected to the component tree still works
|
||||||
|
async test({ assert, logs }) {
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 10));
|
||||||
|
assert.deepEqual(logs, [1]);
|
||||||
|
}
|
||||||
|
});
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
<script>
|
||||||
|
setTimeout(() => {
|
||||||
|
$effect.root(() => {
|
||||||
|
async function fn() {
|
||||||
|
const value = $derived(await 1);
|
||||||
|
return { get value() { return value } };
|
||||||
|
}
|
||||||
|
fn().then(r => console.log(r.value));
|
||||||
|
})
|
||||||
|
})
|
||||||
|
</script>
|
||||||
Loading…
Reference in new issue