From 1c454c236eeb00fab04007b4c8b9ae0f475e9cf6 Mon Sep 17 00:00:00 2001 From: Dominic Gannaway Date: Mon, 18 Nov 2024 14:24:55 +0000 Subject: [PATCH] fix: ensure dynamic call expressions correctly generate output (#14345) --- .changeset/moody-bears-change.md | 5 +++++ .../src/compiler/phases/2-analyze/visitors/CallExpression.js | 2 ++ .../samples/inline-expressions-subtree/_config.js | 5 +++++ .../samples/inline-expressions-subtree/main.svelte | 4 ++++ 4 files changed, 16 insertions(+) create mode 100644 .changeset/moody-bears-change.md create mode 100644 packages/svelte/tests/runtime-legacy/samples/inline-expressions-subtree/_config.js create mode 100644 packages/svelte/tests/runtime-legacy/samples/inline-expressions-subtree/main.svelte diff --git a/.changeset/moody-bears-change.md b/.changeset/moody-bears-change.md new file mode 100644 index 0000000000..0bf32026d2 --- /dev/null +++ b/.changeset/moody-bears-change.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: ensure dynamic call expressions correctly generate output diff --git a/packages/svelte/src/compiler/phases/2-analyze/visitors/CallExpression.js b/packages/svelte/src/compiler/phases/2-analyze/visitors/CallExpression.js index 2ae32e80e1..fe3f638a69 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/visitors/CallExpression.js +++ b/packages/svelte/src/compiler/phases/2-analyze/visitors/CallExpression.js @@ -5,6 +5,7 @@ import { get_rune } from '../../scope.js'; import * as e from '../../../errors.js'; import { get_parent, unwrap_optional } from '../../../utils/ast.js'; import { is_pure, is_safe_identifier } from './shared/utils.js'; +import { mark_subtree_dynamic } from './shared/fragment.js'; /** * @param {CallExpression} node @@ -179,6 +180,7 @@ export function CallExpression(node, context) { context.state.expression.has_call = true; context.state.expression.has_state = true; context.state.expression.can_inline = false; + mark_subtree_dynamic(context.path); } } } diff --git a/packages/svelte/tests/runtime-legacy/samples/inline-expressions-subtree/_config.js b/packages/svelte/tests/runtime-legacy/samples/inline-expressions-subtree/_config.js new file mode 100644 index 0000000000..17c573a510 --- /dev/null +++ b/packages/svelte/tests/runtime-legacy/samples/inline-expressions-subtree/_config.js @@ -0,0 +1,5 @@ +import { test } from '../../test'; + +export default test({ + html: 'A\n
B
' +}); diff --git a/packages/svelte/tests/runtime-legacy/samples/inline-expressions-subtree/main.svelte b/packages/svelte/tests/runtime-legacy/samples/inline-expressions-subtree/main.svelte new file mode 100644 index 0000000000..555dc8af23 --- /dev/null +++ b/packages/svelte/tests/runtime-legacy/samples/inline-expressions-subtree/main.svelte @@ -0,0 +1,4 @@ + 'red')()}>A +
+ 'red')()}>B +