Skip to content

fix: update_version after delete if source is undefined and prop in target #15796

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 3 commits into from
Apr 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/great-colts-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: `update_version` after `delete` if `source` is `undefined` and `prop` in `target`
1 change: 1 addition & 0 deletions packages/svelte/src/internal/client/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export function proxy(value) {
prop,
with_parent(() => source(UNINITIALIZED, stack))
);
update_version(version);
}
} else {
// When working with arrays, we need to also ensure we update the length when removing
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { test } from '../../test';
import { flushSync } from 'svelte';

export default test({
html: `<button>delete</button><p>test</p>`,

async test({ assert, target }) {
const btn = target.querySelector('button');

flushSync(() => btn?.click());
assert.htmlEqual(target.innerHTML, '<button>delete</button>');
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<script>
let obj = $state({test: 0})

let keys = $derived(Object.keys(obj));
</script>

<button onclick={() => delete obj.test}>
delete
</button>

{#each keys as key}
<p>{key}</p>
{/each}