mirror of https://github.com/sveltejs/svelte
fix: improve unowned derived signal heuristics (#11029)
* fix: improve unowned derived signal heuristics * spellingpull/11018/head
parent
2a784fce16
commit
1d52c1323b
@ -0,0 +1,5 @@
|
||||
---
|
||||
"svelte": patch
|
||||
---
|
||||
|
||||
fix: improve unowned derived signal heuristics
|
@ -0,0 +1,17 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
async test({ assert, target }) {
|
||||
let [btn1] = target.querySelectorAll('button');
|
||||
|
||||
flushSync(() => {
|
||||
btn1.click();
|
||||
});
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`<button>update</button><div>2</div><div>2</div><div>2</div><div>2</div>`
|
||||
);
|
||||
}
|
||||
});
|
@ -0,0 +1,33 @@
|
||||
<script>
|
||||
let thing = $state();
|
||||
|
||||
function update() {
|
||||
let data = $state({ name: 1, position: 1 });
|
||||
let position = $derived(data.position);
|
||||
let name = $derived(data.name);
|
||||
|
||||
thing = {
|
||||
get data() { return data },
|
||||
get position() { return position },
|
||||
get name() { return name },
|
||||
}
|
||||
|
||||
thing.position;
|
||||
data = { name: 2, position: 2 };
|
||||
}
|
||||
</script>
|
||||
|
||||
<button onclick={update}>update</button>
|
||||
|
||||
<div>
|
||||
{thing?.data?.name}
|
||||
</div>
|
||||
<div>
|
||||
{thing?.name}
|
||||
</div>
|
||||
<div>
|
||||
{thing?.data?.position}
|
||||
</div>
|
||||
<div>
|
||||
{thing?.position}
|
||||
</div>
|
Loading…
Reference in new issue