mirror of https://github.com/sveltejs/svelte
commit
056b4a52de
@ -0,0 +1 @@
|
||||
<button on:click><slot></slot></button>
|
@ -0,0 +1,16 @@
|
||||
export default {
|
||||
html: `
|
||||
<button>0</button>
|
||||
`,
|
||||
|
||||
async test({ assert, component, target, window }) {
|
||||
const button = target.querySelector('button');
|
||||
const event = new window.MouseEvent('click');
|
||||
|
||||
await button.dispatchEvent(event);
|
||||
assert.equal(component.count, 1);
|
||||
|
||||
await button.dispatchEvent(event);
|
||||
assert.equal(component.count, 1);
|
||||
}
|
||||
};
|
@ -0,0 +1,6 @@
|
||||
<script>
|
||||
import Button from './Button.svelte';
|
||||
export let count = 0;
|
||||
</script>
|
||||
|
||||
<Button on:click|once="{() => count += 1}">{count}</Button>
|
@ -0,0 +1,15 @@
|
||||
[{
|
||||
"message": "Event modifiers other than 'once' can only be used on DOM elements",
|
||||
"code": "invalid-event-modifier",
|
||||
"start": {
|
||||
"line": 6,
|
||||
"column": 8,
|
||||
"character": 93
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 40,
|
||||
"character": 125
|
||||
},
|
||||
"pos": 93
|
||||
}]
|
@ -0,0 +1,6 @@
|
||||
<script>
|
||||
import Button from './Button.svelte';
|
||||
const doThat = () => {};
|
||||
</script>
|
||||
|
||||
<Button on:click|preventDefault={doThat}></Button>
|
Loading…
Reference in new issue