diff --git a/.changeset/popular-apes-bathe.md b/.changeset/popular-apes-bathe.md new file mode 100644 index 0000000000..1277487122 --- /dev/null +++ b/.changeset/popular-apes-bathe.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: skip deriveds for props with known safe calls diff --git a/packages/svelte/src/compiler/phases/2-analyze/index.js b/packages/svelte/src/compiler/phases/2-analyze/index.js index 5a0adfc40c..7c4c65d57a 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/index.js +++ b/packages/svelte/src/compiler/phases/2-analyze/index.js @@ -1042,6 +1042,9 @@ function is_known_safe_call(node, context) { return true; } } + + // TODO add more cases + return false; } @@ -1262,11 +1265,12 @@ const common_visitors = { } }, CallExpression(node, context) { + const { expression } = context.state; if ( - context.state.expression?.type === 'ExpressionTag' || - (context.state.expression?.type === 'SpreadAttribute' && !is_known_safe_call(node, context)) + (expression?.type === 'ExpressionTag' || expression?.type === 'SpreadAttribute') && + !is_known_safe_call(node, context) ) { - context.state.expression.metadata.contains_call_expression = true; + expression.metadata.contains_call_expression = true; } const callee = node.callee;