forked from sveltejs/svelte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix invalidation in ++foo.bar (sveltejs#4395)
- Loading branch information
1 parent
de31fc5
commit 98aba12
Showing
4 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
test/runtime/samples/instrumentation-update-expression/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
export default { | ||
html: ` | ||
<p>0</p> | ||
<button>foo++</button> | ||
<button>++foo</button> | ||
<p>0</p> | ||
<button>bar.bar++</button> | ||
<button>++bar.bar</button> | ||
`, | ||
async test({ assert, target, window }) { | ||
const [foo, bar] = target.querySelectorAll('p'); | ||
const [button1, button2, button3, button4] = target.querySelectorAll('button'); | ||
const event = new window.MouseEvent('click'); | ||
|
||
await button1.dispatchEvent(event); | ||
assert.equal(foo.innerHTML, '1'); | ||
assert.equal(bar.innerHTML, '0'); | ||
|
||
await button2.dispatchEvent(event); | ||
assert.equal(foo.innerHTML, '2'); | ||
assert.equal(bar.innerHTML, '0'); | ||
|
||
await button3.dispatchEvent(event); | ||
assert.equal(foo.innerHTML, '2'); | ||
assert.equal(bar.innerHTML, '1'); | ||
|
||
await button4.dispatchEvent(event); | ||
assert.equal(foo.innerHTML, '2'); | ||
assert.equal(bar.innerHTML, '2'); | ||
} | ||
}; |
14 changes: 14 additions & 0 deletions
14
test/runtime/samples/instrumentation-update-expression/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<script> | ||
let foo = 0; | ||
let bar = { bar: 0 }; | ||
</script> | ||
|
||
<p>{foo}</p> | ||
|
||
<button on:click={() => foo++}>foo++</button> | ||
<button on:click={() => ++foo}>++foo</button> | ||
|
||
<p>{bar.bar}</p> | ||
|
||
<button on:click={() => bar.bar++}>bar.bar++</button> | ||
<button on:click={() => ++bar.bar}>++bar.bar</button> |