diff --git a/src/compiler/compile/nodes/shared/Expression.ts b/src/compiler/compile/nodes/shared/Expression.ts index e85c1de5e5..b9d54bea04 100644 --- a/src/compiler/compile/nodes/shared/Expression.ts +++ b/src/compiler/compile/nodes/shared/Expression.ts @@ -442,6 +442,10 @@ export default class Expression { `); } + if (parent && parent.method) { + code.prependRight(node.start, ': '); + } + function_expression = null; dependencies = null; contextual_dependencies = null; diff --git a/test/runtime/samples/shorthand-method-in-template/Foo.svelte b/test/runtime/samples/shorthand-method-in-template/Foo.svelte new file mode 100644 index 0000000000..bbe542622d --- /dev/null +++ b/test/runtime/samples/shorthand-method-in-template/Foo.svelte @@ -0,0 +1,5 @@ + + +{bar.answer()} \ No newline at end of file diff --git a/test/runtime/samples/shorthand-method-in-template/_config.js b/test/runtime/samples/shorthand-method-in-template/_config.js new file mode 100644 index 0000000000..ddd282644d --- /dev/null +++ b/test/runtime/samples/shorthand-method-in-template/_config.js @@ -0,0 +1,3 @@ +export default { + html: '42' +}; \ No newline at end of file diff --git a/test/runtime/samples/shorthand-method-in-template/main.svelte b/test/runtime/samples/shorthand-method-in-template/main.svelte new file mode 100644 index 0000000000..9ebd11aacb --- /dev/null +++ b/test/runtime/samples/shorthand-method-in-template/main.svelte @@ -0,0 +1,9 @@ + + + \ No newline at end of file