Skip to content

Commit 8be9f5c

Browse files
committed
fix: ensure event handlers containing arguments are not hoisted
1 parent aaa1797 commit 8be9f5c

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

.changeset/serious-socks-cover.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: ensure event handlers containing arguments are not hoisted

packages/svelte/src/compiler/phases/2-analyze/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ function get_delegated_event(node, context) {
168168

169169
const scope = target_function.metadata.scope;
170170
for (const [reference] of scope.references) {
171+
// We can't hoist functions that contain the arguments keyword
172+
if (reference === 'arguments') {
173+
return non_hoistable;
174+
}
171175
const binding = scope.get(reference);
172176

173177
if (

0 commit comments

Comments
 (0)