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; }