-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ensure hoisted event handler names are globally unique — fixes #466
- Loading branch information
1 parent
c61ce13
commit 352bb3d
Showing
3 changed files
with
46 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
36 changes: 36 additions & 0 deletions
36
test/runtime/samples/event-handler-each-deconflicted/_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,36 @@ | ||
export default { | ||
data: { | ||
foo: [ 1 ], | ||
bar: [ 2 ], | ||
clicked: 'neither' | ||
}, | ||
|
||
html: ` | ||
<button>foo</button> | ||
<button>bar</button> | ||
<p>clicked: neither</p> | ||
`, | ||
|
||
test ( assert, component, target, window ) { | ||
const buttons = target.querySelectorAll( 'button' ); | ||
const event = new window.MouseEvent( 'click' ); | ||
|
||
buttons[0].dispatchEvent( event ); | ||
assert.equal( component.get( 'clicked' ), 'foo' ); | ||
assert.htmlEqual( target.innerHTML, ` | ||
<button>foo</button> | ||
<button>bar</button> | ||
<p>clicked: foo</p> | ||
` ); | ||
|
||
buttons[1].dispatchEvent( event ); | ||
assert.equal( component.get( 'clicked' ), 'bar' ); | ||
assert.htmlEqual( target.innerHTML, ` | ||
<button>foo</button> | ||
<button>bar</button> | ||
<p>clicked: bar</p> | ||
` ); | ||
|
||
component.destroy(); | ||
} | ||
}; |
9 changes: 9 additions & 0 deletions
9
test/runtime/samples/event-handler-each-deconflicted/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 @@ | ||
{{#each foo as f}} | ||
<button on:click='set({ clicked: "foo" })'>foo</button> | ||
{{/each}} | ||
|
||
{{#each bar as b}} | ||
<button on:click='set({ clicked: "bar" })'>bar</button> | ||
{{/each}} | ||
|
||
<p>clicked: {{clicked}}</p> |