fix: prevent var name clashing for delegated events without params (#13896)

pull/13899/head
Paolo Ricciuti 2 weeks ago committed by GitHub
parent dee8db53df
commit 3147287813
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: prevent var name clashing for delegated events without params

@ -136,7 +136,7 @@ export function build_hoisted_params(node, context) {
if (node.params.length === 0) {
if (hoisted_params.length > 0) {
// For the event object
params.push(b.id('_'));
params.push(b.id(context.state.scope.generate('_')));
}
} else {
for (const param of node.params) {

@ -0,0 +1,14 @@
import { flushSync } from 'svelte';
import { test } from '../../test';
export default test({
mode: ['client'],
test({ assert, target, logs }) {
const btn = target.querySelector('button');
flushSync(() => {
btn?.click();
});
assert.deepEqual(logs, ['test']);
}
});

@ -0,0 +1,6 @@
<svelte:options runes />
<script>
let _ = "test"
</script>
<button onclick={() => { console.log(_)} }></button>
Loading…
Cancel
Save