From 1fe0152dd435ef7a0bda819b13c7bfa970819495 Mon Sep 17 00:00:00 2001 From: Simon H <5968653+dummdidumm@users.noreply.github.com> Date: Thu, 30 Nov 2023 09:29:04 +0100 Subject: [PATCH] fix: delegate events on elements with bind-this (#9696) fixes #9688 --- .changeset/chatty-taxis-juggle.md | 5 +++++ packages/svelte/src/compiler/phases/2-analyze/index.js | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changeset/chatty-taxis-juggle.md diff --git a/.changeset/chatty-taxis-juggle.md b/.changeset/chatty-taxis-juggle.md new file mode 100644 index 0000000000..34eb8bc9a9 --- /dev/null +++ b/.changeset/chatty-taxis-juggle.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: delegate events on elements with bind-this diff --git a/packages/svelte/src/compiler/phases/2-analyze/index.js b/packages/svelte/src/compiler/phases/2-analyze/index.js index aa0bba702f..ef5d807bb9 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/index.js +++ b/packages/svelte/src/compiler/phases/2-analyze/index.js @@ -1106,7 +1106,8 @@ function determine_element_spread_and_delegatable(node) { has_spread = true; } else if ( !has_action_or_bind && - (attribute.type === 'BindDirective' || attribute.type === 'UseDirective') + ((attribute.type === 'BindDirective' && attribute.name !== 'this') || + attribute.type === 'UseDirective') ) { has_action_or_bind = true; }