diff --git a/CHANGELOG.md b/CHANGELOG.md index e357e58acdc8..c2611da704bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * Allow exiting a reactive block early with `break $` ([#2828](https://github.com/sveltejs/svelte/issues/2828)) * Check attributes have changed before setting them to avoid image flicker ([#3579](https://github.com/sveltejs/svelte/pull/3579)) * Fix generating malformed code for `{@debug}` tags with no dependencies ([#3588](https://github.com/sveltejs/svelte/issue/3588)) +* Fix `bind:this` binding to a store ([#3591](https://github.com/sveltejs/svelte/issue/3591)) * Use safer `HTMLElement` check before extending class ([#3608](https://github.com/sveltejs/svelte/issue/3608)) * Add `location` as a known global ([#3619](https://github.com/sveltejs/svelte/pull/3619)) * Support `{#await}` with `{:catch}` but no `{:then}` ([#3623](https://github.com/sveltejs/svelte/issues/3623)) diff --git a/src/compiler/compile/Component.ts b/src/compiler/compile/Component.ts index 20c0d09e2472..8d1384e7a1d7 100644 --- a/src/compiler/compile/Component.ts +++ b/src/compiler/compile/Component.ts @@ -764,7 +764,7 @@ export default class Component { } if (name[0] === '$' && name[1] !== '$') { - return x`${name.slice(1)}.set(${name})`; + return x`${name.slice(1)}.set(${value || name})`; } if ( diff --git a/test/runtime/samples/binding-this-store/_config.js b/test/runtime/samples/binding-this-store/_config.js new file mode 100644 index 000000000000..f818c2e31e4b --- /dev/null +++ b/test/runtime/samples/binding-this-store/_config.js @@ -0,0 +1,4 @@ +export default { + skip_if_ssr: true, + html: `