mirror of https://github.com/sveltejs/svelte
allow nullish values for component event handlers (#7863)
parent
25a05bf952
commit
b20fb114a6
@ -0,0 +1,14 @@
|
||||
<script>
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
const dispatch = createEventDispatcher();
|
||||
export let logs;
|
||||
|
||||
function click() {
|
||||
try {
|
||||
dispatch('click');
|
||||
} catch (error) {
|
||||
logs.push(error);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<button on:click={click} />
|
@ -0,0 +1,9 @@
|
||||
export default {
|
||||
async test({ assert, component, window, target }) {
|
||||
const event = new window.MouseEvent('click');
|
||||
const button = target.querySelector('button');
|
||||
|
||||
await button.dispatchEvent(event);
|
||||
assert.equal(component.logs.length, 0);
|
||||
}
|
||||
};
|
@ -0,0 +1,6 @@
|
||||
<script>
|
||||
import Widget from './Widget.svelte';
|
||||
export let logs = [];
|
||||
</script>
|
||||
|
||||
<Widget on:click={null} {logs} />
|
Loading…
Reference in new issue