Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>