mirror of https://github.com/sveltejs/svelte
Merge pull request #1427 from sveltejs/dynamic-component-shorthand-event
fix handling of shorthand event handler in dynamic componentspull/1429/head
commit
53816ee5c5
@ -0,0 +1 @@
|
||||
<button on:click='fire("foo", { answer: 42 })'>click me</button>
|
@ -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);
|
||||
}
|
||||
};
|
@ -0,0 +1,9 @@
|
||||
<svelte:component this={Widget} on:foo/>
|
||||
|
||||
<script>
|
||||
import Widget from './Widget.html';
|
||||
|
||||
export default {
|
||||
data: () => ({ Widget })
|
||||
};
|
||||
</script>
|
Loading…
Reference in new issue