mirror of https://github.com/sveltejs/svelte
Fix unowned bug 2 (#11077)
* fix: improve handled of unowned derived signals * fix: improve handled of unowned derived signals * lintpull/11072/head
parent
071d6314d9
commit
452749494e
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"svelte": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: improve handled of unowned derived signals
|
@ -0,0 +1,12 @@
|
|||||||
|
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