mirror of https://github.com/sveltejs/svelte
parent
b13d331f78
commit
8f8cbdc01f
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
feat: warn on invalid event handlers
|
||||
@ -0,0 +1,17 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
mode: ['client'],
|
||||
|
||||
compileOptions: {
|
||||
dev: true
|
||||
},
|
||||
|
||||
test({ assert, target, warnings }) {
|
||||
target.querySelector('button')?.click();
|
||||
|
||||
assert.deepEqual(warnings, [
|
||||
'`click` handler at main.svelte:9:17 should be a function. Did you mean to remove the trailing `()`?'
|
||||
]);
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,11 @@
|
||||
<script>
|
||||
let count = $state(0);
|
||||
|
||||
function increment() {
|
||||
count += 1;
|
||||
}
|
||||
</script>
|
||||
|
||||
<button onclick={increment()}>
|
||||
clicks: {count}
|
||||
</button>
|
||||
Loading…
Reference in new issue