Skip to content

Commit

Permalink
fix: prevent var name clashing for delegated events without params (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
paoloricciuti authored Oct 24, 2024
1 parent dee8db5 commit 3147287
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/smooth-dragons-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: prevent var name clashing for delegated events without params
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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']);
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<svelte:options runes />
<script>
let _ = "test"
</script>

<button onclick={() => { console.log(_)} }></button>

0 comments on commit 3147287

Please sign in to comment.