Skip to content

Commit 3b0c6a1

Browse files
committed
fix $$invalidate getting confused by an undefined third argument (#4170)
1 parent 741444d commit 3b0c6a1

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
* Prevent text input cursor jumping in Safari with one-way binding ([#3449](https://github.com/sveltejs/svelte/issues/3449))
66
* Expose compiler version in dev events ([#4047](https://github.com/sveltejs/svelte/issues/4047))
7+
* Fix reactive assignments with destructuring and stores where the destructured value should be undefined ([#4170](https://github.com/sveltejs/svelte/issues/4170))
78
* Do not automatically declare variables in reactive declarations when assigning to a member expression ([#4212](https://github.com/sveltejs/svelte/issues/4212))
89

910
## 3.16.7

src/runtime/internal/Component.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ export function init(component, options, instance, create_fragment, not_equal, p
127127
let ready = false;
128128

129129
$$.ctx = instance
130-
? instance(component, prop_values, (i, ret, value = ret) => {
130+
? instance(component, prop_values, (i, ret, ...rest) => {
131+
const value = rest.length ? rest[0] : ret;
131132
if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {
132133
if ($$.bound[i]) $$.bound[i](value);
133134
if (ready) make_dirty(component, i);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default {
2+
html: `
3+
<p>undefined</p>
4+
<p>undefined</p>
5+
`
6+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<script>
2+
import { writable } from 'svelte/store';
3+
const store = writable([]);
4+
$: ({ foo1 } = $store);
5+
$: [foo2] = $store;
6+
</script>
7+
8+
<p>{foo1}</p>
9+
<p>{foo2}</p>

0 commit comments

Comments
 (0)