diff --git a/.changeset/gentle-trees-exercise.md b/.changeset/gentle-trees-exercise.md new file mode 100644 index 000000000000..7f658692b5d3 --- /dev/null +++ b/.changeset/gentle-trees-exercise.md @@ -0,0 +1,5 @@ +--- +"svelte": patch +--- + +fix: allow for non optional chain call expression in render diff --git a/packages/svelte/src/compiler/phases/1-parse/state/tag.js b/packages/svelte/src/compiler/phases/1-parse/state/tag.js index 9e797f4c5794..3909a5f90e28 100644 --- a/packages/svelte/src/compiler/phases/1-parse/state/tag.js +++ b/packages/svelte/src/compiler/phases/1-parse/state/tag.js @@ -587,9 +587,7 @@ function special(parser) { if ( expression.type !== 'CallExpression' && - (expression.type !== 'ChainExpression' || - expression.expression.type !== 'CallExpression' || - !expression.expression.optional) + (expression.type !== 'ChainExpression' || expression.expression.type !== 'CallExpression') ) { e.render_tag_invalid_expression(expression); } diff --git a/packages/svelte/tests/runtime-runes/samples/snippet-expressions/_config.js b/packages/svelte/tests/runtime-runes/samples/snippet-expressions/_config.js index 3ae1bd835850..99568fe49395 100644 --- a/packages/svelte/tests/runtime-runes/samples/snippet-expressions/_config.js +++ b/packages/svelte/tests/runtime-runes/samples/snippet-expressions/_config.js @@ -10,6 +10,10 @@ export default test({
foo
foo
+foo
+bar
foo
foo
+foo
+foo
` ); diff --git a/packages/svelte/tests/runtime-runes/samples/snippet-expressions/child.svelte b/packages/svelte/tests/runtime-runes/samples/snippet-expressions/child.svelte index 2713f7d9897a..51be4835ebd5 100644 --- a/packages/svelte/tests/runtime-runes/samples/snippet-expressions/child.svelte +++ b/packages/svelte/tests/runtime-runes/samples/snippet-expressions/child.svelte @@ -12,6 +12,10 @@