Skip to content

Commit

Permalink
Merge pull request #2619 from sveltejs/gh-2435
Browse files Browse the repository at this point in the history
fix resubscriptions inside script block
  • Loading branch information
Rich-Harris authored May 4, 2019
2 parents 1eca19f + 0d890b1 commit 6240ed0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compile/render-dom/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export default function dom(
const variable = component.var_lookup.get(name);
if (variable && (variable.hoistable || variable.global || variable.module)) return;

if (single) {
if (single && !(variable.subscribable && variable.reassigned)) {
code.prependRight(node.start, `$$invalidate('${name}', `);
code.appendLeft(node.end, `)`);
} else {
Expand Down
3 changes: 3 additions & 0 deletions test/runtime/samples/store-resubscribe-b/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
html: `42`,
};
7 changes: 7 additions & 0 deletions test/runtime/samples/store-resubscribe-b/main.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script>
import { writable } from 'svelte/store';
let foo = writable(0);
foo = writable(42);
</script>

{$foo}

0 comments on commit 6240ed0

Please sign in to comment.