Skip to content

Commit

Permalink
Merge pull request #2631 from EmilTholin/reactive-values-fixed
Browse files Browse the repository at this point in the history
Check 'injected' and 'fixed_reactive_declarations' independently
  • Loading branch information
Rich-Harris authored May 4, 2019
2 parents cfb22e4 + 0e0da70 commit 1eca19f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/compile/render-dom/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,14 +413,15 @@ export default function dom(
${set && `$$self.$set = ${set};`}
${reactive_declarations.length > 0 && deindent`
${injected.length && `let ${injected.join(', ')};`}
${reactive_declarations.length > 0 && deindent`
$$self.$$.update = ($$dirty = { ${Array.from(all_reactive_dependencies).map(n => `${n}: 1`).join(', ')} }) => {
${reactive_declarations}
};
`}
${fixed_reactive_declarations}
`}
return ${stringify_props(filtered_declarations)};
}
Expand Down
11 changes: 11 additions & 0 deletions test/runtime/samples/reactive-values-fixed/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export default {
html: `
<p>4</p>
`,

test({ assert, component, target }) {
assert.htmlEqual(target.innerHTML, `
<p>4</p>
`);
}
};
6 changes: 6 additions & 0 deletions test/runtime/samples/reactive-values-fixed/main.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<script>
const num = 2;
$: squared = num * num;
</script>

<p>{squared}</p>

0 comments on commit 1eca19f

Please sign in to comment.