Skip to content

Commit 1c454c2

Browse files
authored
fix: ensure dynamic call expressions correctly generate output (#14345)
1 parent 24ebbcb commit 1c454c2

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

.changeset/moody-bears-change.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: ensure dynamic call expressions correctly generate output

packages/svelte/src/compiler/phases/2-analyze/visitors/CallExpression.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { get_rune } from '../../scope.js';
55
import * as e from '../../../errors.js';
66
import { get_parent, unwrap_optional } from '../../../utils/ast.js';
77
import { is_pure, is_safe_identifier } from './shared/utils.js';
8+
import { mark_subtree_dynamic } from './shared/fragment.js';
89

910
/**
1011
* @param {CallExpression} node
@@ -179,6 +180,7 @@ export function CallExpression(node, context) {
179180
context.state.expression.has_call = true;
180181
context.state.expression.has_state = true;
181182
context.state.expression.can_inline = false;
183+
mark_subtree_dynamic(context.path);
182184
}
183185
}
184186
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { test } from '../../test';
2+
3+
export default test({
4+
html: '<span class="red">A</span>\n<div><span class="red">B</span></div>'
5+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<span class={(() => 'red')()}>A</span>
2+
<div>
3+
<span class={(() => 'red')()}>B</span>
4+
</div>

0 commit comments

Comments
 (0)