Skip to content

Commit 7e0a81d

Browse files
committed
fix: correctly transform reassignments to class fields in SSR mode
1 parent e5d0cd2 commit 7e0a81d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

.changeset/rude-drinks-relate.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: correctly transform reassignments to class fields in SSR mode

packages/svelte/src/compiler/phases/3-transform/server/visitors/AssignmentExpression.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ export function AssignmentExpression(node, context) {
2424
* @returns {Expression | null}
2525
*/
2626
function build_assignment(operator, left, right, context) {
27-
if (context.state.analysis.runes && left.type === 'MemberExpression') {
27+
if (
28+
context.state.analysis.runes &&
29+
left.type === 'MemberExpression' &&
30+
left.object.type === 'ThisExpression' &&
31+
!left.computed
32+
) {
2833
const name = get_name(left.property);
2934
const field = name && context.state.state_fields.get(name);
3035

0 commit comments

Comments
 (0)