mirror of https://github.com/sveltejs/svelte
only overwrite this in event handlers for custom events - fixes #1390
parent
afb6d07991
commit
49a09ef847
@ -0,0 +1,28 @@
|
|||||||
|
export default {
|
||||||
|
data: {
|
||||||
|
items: ['foo', 'bar', 'baz'],
|
||||||
|
},
|
||||||
|
|
||||||
|
html: `
|
||||||
|
<button>foo</button>
|
||||||
|
<button>bar</button>
|
||||||
|
<button>baz</button>
|
||||||
|
`,
|
||||||
|
|
||||||
|
test(assert, component, target, window) {
|
||||||
|
const buttons = target.querySelectorAll('button');
|
||||||
|
const event = new window.MouseEvent('click');
|
||||||
|
|
||||||
|
const clicked = [];
|
||||||
|
|
||||||
|
component.on('clicked', event => {
|
||||||
|
clicked.push(event.node);
|
||||||
|
});
|
||||||
|
|
||||||
|
buttons[1].dispatchEvent(event);
|
||||||
|
|
||||||
|
assert.equal(clicked.length, 1);
|
||||||
|
assert.equal(clicked[0].nodeName, 'BUTTON');
|
||||||
|
assert.equal(clicked[0].textContent, 'bar');
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,3 @@
|
|||||||
|
{#each items as item}
|
||||||
|
<button on:click='fire("clicked", { node: this })'>{item}</button>
|
||||||
|
{/each}
|
Loading…
Reference in new issue