Skip to content

Commit

Permalink
fix bind:this binding to a store (sveltejs#3591)
Browse files Browse the repository at this point in the history
  • Loading branch information
Conduitry authored Oct 19, 2019
1 parent 2e2b0c9 commit 8d7d0ff
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/compile/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
4 changes: 4 additions & 0 deletions test/runtime/samples/binding-this-store/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default {
skip_if_ssr: true,
html: `<div>object</div>`
};
6 changes: 6 additions & 0 deletions test/runtime/samples/binding-this-store/main.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<script>
import { writable } from 'svelte/store';
const foo = writable();
</script>

<div bind:this={$foo}>{typeof $foo}</div>

0 comments on commit 8d7d0ff

Please sign in to comment.