Skip to content

Commit

Permalink
fix: allow for non optional chain call expression in render (#11578)
Browse files Browse the repository at this point in the history
  • Loading branch information
paoloricciuti authored May 13, 2024
1 parent 61238d0 commit 81517a5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/gentle-trees-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"svelte": patch
---

fix: allow for non optional chain call expression in render
4 changes: 1 addition & 3 deletions packages/svelte/src/compiler/phases/1-parse/state/tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export default test({
<hr>
<p>foo</p>
<hr>
<p>foo</p>
<hr>
<p>foo</p>
<hr>
<p>bar</p>
<hr>
<hr>
Expand All @@ -35,6 +39,10 @@ export default test({
<p>foo</p>
<hr>
<p>foo</p>
<hr>
<p>foo</p>
<hr>
<p>foo</p>
<button>toggle</button>
`
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
<hr>
{@render snippets.foo()}
<hr>
{@render snippets?.foo()}
<hr>
{@render snippets?.foo?.()}
<hr>
{@render snippets.foo?.()}
<hr>
{@render (optional ?? snippets.bar)()}
Expand Down

0 comments on commit 81517a5

Please sign in to comment.