mirror of https://github.com/sveltejs/svelte
parent
b3084bc555
commit
d0bd660b83
@ -0,0 +1,5 @@
|
||||
---
|
||||
"svelte": patch
|
||||
---
|
||||
|
||||
fix: improve handled of unowned derived signals
|
||||
@ -0,0 +1,15 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
async test({ assert, target }) {
|
||||
// The test has a bunch of queueMicrotasks
|
||||
await Promise.resolve();
|
||||
await Promise.resolve();
|
||||
await Promise.resolve();
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`<div>Zeeba Neighba</div>`
|
||||
);
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,34 @@
|
||||
<script context="module">
|
||||
export class Thing {
|
||||
data = $state();
|
||||
|
||||
subscribe() {
|
||||
queueMicrotask(() => {
|
||||
this.data = {
|
||||
name: `Zeeba Neighba`,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
name = $derived(this.data?.name);
|
||||
}
|
||||
|
||||
export class Things {
|
||||
thing = $state();
|
||||
|
||||
subscribe() {
|
||||
queueMicrotask(() => {
|
||||
this.thing = new Thing();
|
||||
this.thing.subscribe();
|
||||
this.thing.name;
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
let model = new Things();
|
||||
$effect(() => model.subscribe());
|
||||
</script>
|
||||
|
||||
<div>{model.thing?.name}</div>
|
||||
Loading…
Reference in new issue