mirror of https://github.com/sveltejs/svelte
fix: ensure event handlers containing arguments are not hoisted (#9758)
* fix: ensure event handlers containing arguments are not hoisted * add test * handle rest argumentspull/9759/head
parent
2017af407d
commit
ef5bcfe542
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: ensure event handlers containing arguments are not hoisted
|
@ -0,0 +1,13 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: `<button>0</button>`,
|
||||
|
||||
async test({ assert, target }) {
|
||||
const [b1] = target.querySelectorAll('button');
|
||||
|
||||
b1?.click();
|
||||
await Promise.resolve();
|
||||
assert.htmlEqual(target.innerHTML, '<button>1</button>');
|
||||
}
|
||||
});
|
@ -0,0 +1,8 @@
|
||||
<script>
|
||||
let count = $state(0);
|
||||
function increment(...args) {
|
||||
count += args.length;
|
||||
}
|
||||
</script>
|
||||
|
||||
<button on:click={increment}>{count}</button>
|
@ -0,0 +1,13 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: `<button>0</button>`,
|
||||
|
||||
async test({ assert, target }) {
|
||||
const [b1] = target.querySelectorAll('button');
|
||||
|
||||
b1?.click();
|
||||
await Promise.resolve();
|
||||
assert.htmlEqual(target.innerHTML, '<button>1</button>');
|
||||
}
|
||||
});
|
@ -0,0 +1,8 @@
|
||||
<script>
|
||||
let count = $state(0);
|
||||
function increment() {
|
||||
count += arguments.length;
|
||||
}
|
||||
</script>
|
||||
|
||||
<button on:click={increment}>{count}</button>
|
Loading…
Reference in new issue