mirror of https://github.com/sveltejs/svelte
Merge pull request #1311 from sveltejs/gh-1278
treat component events the same as element eventspull/1332/head
commit
07a53e55de
@ -0,0 +1 @@
|
||||
<button on:click>click me</button>
|
@ -0,0 +1,25 @@
|
||||
export default {
|
||||
html: '<button>click me</button>',
|
||||
|
||||
test(assert, component, target) {
|
||||
const button = target.querySelector('button');
|
||||
const messages = [];
|
||||
|
||||
const log = console.log;
|
||||
console.log = msg => {
|
||||
messages.push(msg);
|
||||
};
|
||||
|
||||
try {
|
||||
button.dispatchEvent(new window.MouseEvent('click'));
|
||||
assert.deepEqual(messages, [
|
||||
'clicked'
|
||||
]);
|
||||
} catch (err) {
|
||||
console.log = log;
|
||||
throw err;
|
||||
}
|
||||
|
||||
console.log = log;
|
||||
},
|
||||
};
|
@ -0,0 +1,9 @@
|
||||
<Widget on:click="console.log('clicked')"/>
|
||||
|
||||
<script>
|
||||
import Widget from './Widget.html';
|
||||
|
||||
export default {
|
||||
components: { Widget }
|
||||
};
|
||||
</script>
|
Loading…
Reference in new issue