mirror of https://github.com/sveltejs/svelte
fix compound assignment dependencies in reactive statements (#3634)
parent
5e2c524825
commit
02f5efd9e7
@ -0,0 +1,27 @@
|
||||
export default {
|
||||
html: `
|
||||
<button>+1</button>
|
||||
<p>count: 0</p>
|
||||
`,
|
||||
|
||||
async test({ assert, component, target, window }) {
|
||||
const click = new window.MouseEvent('click');
|
||||
const button = target.querySelector('button');
|
||||
|
||||
await button.dispatchEvent(click);
|
||||
|
||||
assert.equal(component.x, 2);
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
<button>+1</button>
|
||||
<p>count: 2</p>
|
||||
`);
|
||||
|
||||
await button.dispatchEvent(click);
|
||||
|
||||
assert.equal(component.x, 6);
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
<button>+1</button>
|
||||
<p>count: 6</p>
|
||||
`);
|
||||
}
|
||||
};
|
@ -0,0 +1,8 @@
|
||||
<script>
|
||||
export let x = 0;
|
||||
|
||||
$: x *= 2;
|
||||
</script>
|
||||
|
||||
<button on:click='{() => x += 1}'>+1</button>
|
||||
<p>count: {x}</p>
|
@ -0,0 +1,29 @@
|
||||
export default {
|
||||
html: `
|
||||
<button>+1</button>
|
||||
<p>count: 1</p>
|
||||
`,
|
||||
|
||||
async test({ assert, component, target, window }) {
|
||||
const click = new window.MouseEvent('click');
|
||||
const button = target.querySelector('button');
|
||||
|
||||
assert.equal(component.x, 1);
|
||||
|
||||
await button.dispatchEvent(click);
|
||||
|
||||
assert.equal(component.x, 3);
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
<button>+1</button>
|
||||
<p>count: 3</p>
|
||||
`);
|
||||
|
||||
await button.dispatchEvent(click);
|
||||
|
||||
assert.equal(component.x, 5);
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
<button>+1</button>
|
||||
<p>count: 5</p>
|
||||
`);
|
||||
}
|
||||
};
|
@ -0,0 +1,12 @@
|
||||
<script>
|
||||
export let x = 0;
|
||||
|
||||
$: x++;
|
||||
|
||||
function onClick() {
|
||||
x += 1;
|
||||
}
|
||||
</script>
|
||||
|
||||
<button on:click='{() => x += 1}'>+1</button>
|
||||
<p>count: {x}</p>
|
Loading…
Reference in new issue