-
-
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.
event propagation shorthand for components (#638)
- Loading branch information
1 parent
51af8c2
commit 1b92f5f
Showing
4 changed files
with
49 additions
and
14 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
1 change: 1 addition & 0 deletions
1
test/runtime/samples/event-handler-shorthand-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-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); | ||
} | ||
}; |
11 changes: 11 additions & 0 deletions
11
test/runtime/samples/event-handler-shorthand-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,11 @@ | ||
<Widget on:foo/> | ||
|
||
<script> | ||
import Widget from './Widget.html'; | ||
|
||
export default { | ||
components: { | ||
Widget | ||
} | ||
}; | ||
</script> |