mirror of https://github.com/sveltejs/svelte
Merge pull request #2755 from EmilTholin/mutated-const-reative-dependency
Set mutated const variables as reactive dependenciespull/2782/head
commit
c67f5348ea
@ -0,0 +1,17 @@
|
|||||||
|
export default {
|
||||||
|
html: `
|
||||||
|
<button>Mutate a</button>
|
||||||
|
<div>{}</div>
|
||||||
|
`,
|
||||||
|
|
||||||
|
async test({ assert, target }) {
|
||||||
|
const button = target.querySelector('button');
|
||||||
|
const click = new window.MouseEvent('click');
|
||||||
|
|
||||||
|
await button.dispatchEvent(click);
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<button>Mutate a</button>
|
||||||
|
<div>{"foo":42}</div>
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,9 @@
|
|||||||
|
<script>
|
||||||
|
const a = {};
|
||||||
|
const b = {};
|
||||||
|
$: b.foo = a.foo;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button on:click={() => a.foo = 42}>Mutate a</button>
|
||||||
|
<div>{JSON.stringify(b)}</div>
|
||||||
|
|
Loading…
Reference in new issue