Skip to content
Closed
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/grumpy-students-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: correctly handle action member expression keys
Original file line number Diff line number Diff line change
Expand Up @@ -2413,12 +2413,20 @@ export const template_visitors = {
if (node.expression) {
params.push(b.id('$$props'));
}
let callee;
if (node.name.includes('.')) {
const parts = node.name.split('.');
callee = serialize_get_binding(b.id(parts[0]), state);
for (let i = 1; i < parts.length; i++) {
const key = b.key(parts[i]);
callee = b.member(callee, key, key.type === 'Literal');
}
} else {
callee = serialize_get_binding(b.id(node.name), state);
}

/** @type {import('estree').Expression[]} */
const args = [
state.node,
b.arrow(params, b.call(serialize_get_binding(b.id(node.name), state), ...params))
];
const args = [state.node, b.arrow(params, b.call(callee, ...params))];

if (node.expression) {
args.push(b.thunk(/** @type {import('estree').Expression} */ (visit(node.expression))));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { test } from '../../test';

export default test({
html: `
<span style="color: red;">Text</span>
`,
ssrHtml: `
<span>Text</span>
`
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<script>
const a = { 'set-color': (node, c) => node.style.color = c };
</script>
<span use:a.set-color={'red'}>Text</span>