-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b31ecc5
commit fcb1a3c
Showing
3 changed files
with
47 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<button on:click='fire("foo")'>click me</button> |
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,27 @@ | ||
export default { | ||
data: { | ||
items: [ 'a', 'b', 'c' ] | ||
}, | ||
|
||
html: ` | ||
<div><button>click me</button><button>click me</button><button>click me</button></div> | ||
`, | ||
|
||
test ( assert, component, target, window ) { | ||
const buttons = target.querySelectorAll( 'button' ); | ||
|
||
const clicks = []; | ||
|
||
component.on( 'foo', item => { | ||
clicks.push( item ); | ||
}); | ||
|
||
const event = new window.MouseEvent( 'click' ); | ||
|
||
buttons[0].dispatchEvent( event ); | ||
buttons[2].dispatchEvent( event ); | ||
|
||
assert.deepEqual( clicks, [ 'a', 'c' ]); | ||
component.teardown(); | ||
} | ||
}; |
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,19 @@ | ||
<div> | ||
{{#each items as item}} | ||
<Widget on:foo='foo(item)'/> | ||
{{/each}} | ||
</div> | ||
|
||
<script> | ||
import Widget from './Widget.html'; | ||
|
||
export default { | ||
components: { Widget }, | ||
|
||
methods: { | ||
foo ( item ) { | ||
this.fire( 'foo', item ); | ||
} | ||
} | ||
}; | ||
</script> |