-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1427 from sveltejs/dynamic-component-shorthand-event
fix handling of shorthand event handler in dynamic components
- Loading branch information
Showing
4 changed files
with
29 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
1 change: 1 addition & 0 deletions
1
test/runtime/samples/event-handler-shorthand-dynamic-component/Widget.html
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 @@ | ||
<button on:click='fire("foo", { answer: 42 })'>click me</button> |
18 changes: 18 additions & 0 deletions
18
test/runtime/samples/event-handler-shorthand-dynamic-component/_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,18 @@ | ||
export default { | ||
html: ` | ||
<button>click me</button> | ||
`, | ||
|
||
test (assert, component, target, window) { | ||
const button = target.querySelector('button'); | ||
const event = new window.MouseEvent('click'); | ||
|
||
let answer; | ||
component.on('foo', event => { | ||
answer = event.answer; | ||
}); | ||
|
||
button.dispatchEvent(event); | ||
assert.equal(answer, 42); | ||
} | ||
}; |
9 changes: 9 additions & 0 deletions
9
test/runtime/samples/event-handler-shorthand-dynamic-component/main.html
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,9 @@ | ||
<svelte:component this={Widget} on:foo/> | ||
|
||
<script> | ||
import Widget from './Widget.html'; | ||
|
||
export default { | ||
data: () => ({ Widget }) | ||
}; | ||
</script> |