diff --git a/src/compiler/compile/render_dom/wrappers/shared/add_actions.ts b/src/compiler/compile/render_dom/wrappers/shared/add_actions.ts index 6ca7de9a22..85aee6cd36 100644 --- a/src/compiler/compile/render_dom/wrappers/shared/add_actions.ts +++ b/src/compiler/compile/render_dom/wrappers/shared/add_actions.ts @@ -31,8 +31,9 @@ export function add_action(block: Block, target: string, action: Action) { const fn = block.renderer.reference(obj); if (properties.length) { + const member_expression = properties.reduce((lhs, rhs) => x`${lhs}.${rhs}`, fn); block.event_listeners.push( - x`@action_destroyer(${id} = ${fn}.${properties.join('.')}(${target}, ${snippet}))` + x`@action_destroyer(${id} = ${member_expression}(${target}, ${snippet}))` ); } else { block.event_listeners.push( diff --git a/test/runtime/samples/action-object-deep/_config.js b/test/runtime/samples/action-object-deep/_config.js new file mode 100644 index 0000000000..7fdc11af2b --- /dev/null +++ b/test/runtime/samples/action-object-deep/_config.js @@ -0,0 +1,8 @@ +export default { + html: ` + + `, + async test({ assert, target, window }) { + assert.equal(target.querySelector('button').foo, 'bar1337'); + } +}; diff --git a/test/runtime/samples/action-object-deep/main.svelte b/test/runtime/samples/action-object-deep/main.svelte new file mode 100644 index 0000000000..75c35d628d --- /dev/null +++ b/test/runtime/samples/action-object-deep/main.svelte @@ -0,0 +1,12 @@ + + + \ No newline at end of file