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 dynamic event handler for bind variables
- Loading branch information
1 parent
9e9b9a6
commit d600b35
Showing
4 changed files
with
55 additions
and
5 deletions.
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
7 changes: 7 additions & 0 deletions
7
test/runtime/samples/event-handler-dynamic-bound-var/Nested.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,7 @@ | ||
<script> | ||
let text = 'Hello World'; | ||
export function updateText() { | ||
text = 'Bye World'; | ||
} | ||
</script> | ||
{text} |
20 changes: 20 additions & 0 deletions
20
test/runtime/samples/event-handler-dynamic-bound-var/_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,20 @@ | ||
export default { | ||
html: ` | ||
<button>Click Me</button> | ||
Hello World | ||
`, | ||
async test({ assert, component, target, window }) { | ||
const button = target.querySelector('button'); | ||
|
||
const event = new window.MouseEvent('click'); | ||
|
||
await button.dispatchEvent(event); | ||
assert.htmlEqual( | ||
target.innerHTML, | ||
` | ||
<button>Click Me</button> | ||
Bye World | ||
` | ||
); | ||
}, | ||
}; |
8 changes: 8 additions & 0 deletions
8
test/runtime/samples/event-handler-dynamic-bound-var/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,8 @@ | ||
<script> | ||
import Nested from './Nested.svelte'; | ||
let nested; | ||
</script> | ||
|
||
<button on:click={nested && nested.updateText}>Click Me</button> | ||
|
||
<Nested bind:this={nested} /> |