Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/moody-bears-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: ensure dynamic call expressions correctly generate output
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is good, just for the sake of it, can we check wherever else we set can_inline to false to see if the subtree is actually marked dynamic?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it to other places but didn't notice any differences. Which was odd, but this whole inline/dynamic system feels a bit wonky tbh.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah i think we need to restructure this a bit to keep a single source of truth (but i think it will be difficult)

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { test } from '../../test';

export default test({
html: '<span class="red">A</span>\n<div><span class="red">B</span></div>'
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<span class={(() => 'red')()}>A</span>
<div>
<span class={(() => 'red')()}>B</span>
</div>
Loading