Skip to content

Commit 3d80884

Browse files
fix: update_version after delete if source is undefined and prop in target (#15796)
* fix: `update_version` after `delete` if `source` is `undefined` and `prop` in `target` * chore: remove submodule * tweak test --------- Co-authored-by: Rich Harris <[email protected]>
1 parent d8c6afd commit 3d80884

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

Diff for: .changeset/great-colts-film.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: `update_version` after `delete` if `source` is `undefined` and `prop` in `target`

Diff for: packages/svelte/src/internal/client/proxy.js

+1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ export function proxy(value) {
100100
prop,
101101
with_parent(() => source(UNINITIALIZED, stack))
102102
);
103+
update_version(version);
103104
}
104105
} else {
105106
// When working with arrays, we need to also ensure we update the length when removing
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { test } from '../../test';
2+
import { flushSync } from 'svelte';
3+
4+
export default test({
5+
html: `<button>delete</button><p>test</p>`,
6+
7+
async test({ assert, target }) {
8+
const btn = target.querySelector('button');
9+
10+
flushSync(() => btn?.click());
11+
assert.htmlEqual(target.innerHTML, '<button>delete</button>');
12+
}
13+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<script>
2+
let obj = $state({test: 0})
3+
4+
let keys = $derived(Object.keys(obj));
5+
</script>
6+
7+
<button onclick={() => delete obj.test}>
8+
delete
9+
</button>
10+
11+
{#each keys as key}
12+
<p>{key}</p>
13+
{/each}

0 commit comments

Comments
 (0)