Skip to content

Commit 520d3fc

Browse files
committed
tweak
1 parent ca3330c commit 520d3fc

File tree

1 file changed

+13
-14
lines changed
  • packages/svelte/src/compiler/phases/3-transform/client/visitors

1 file changed

+13
-14
lines changed

packages/svelte/src/compiler/phases/3-transform/client/visitors/ClassBody.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/** @import { Context } from '../types' */
44
import * as b from '#compiler/builders';
55
import { dev } from '../../../../state.js';
6+
import { get_parent } from '../../../../utils/ast.js';
67
import { get_name } from '../../../nodes.js';
78

89
/**
@@ -76,23 +77,21 @@ export function ClassBody(node, context) {
7677
if (dev) value = b.call('$.tag', value, b.literal(name));
7778
body.push(b.prop_def(definition.key, value));
7879
} else if (field.node === definition) {
79-
const member = b.member(b.this, field.key);
80+
let call = /** @type {CallExpression} */ (context.visit(field.value, child_state));
81+
82+
if (dev) {
83+
const declaration = /** @type {ClassDeclaration | ClassExpression} */ (
84+
get_parent(context.path, -1)
85+
);
86+
87+
call = b.call('$.tag', call, b.literal(`${declaration.id?.name ?? '[class]'}.${name}`));
88+
}
8089

90+
const member = b.member(b.this, field.key);
8191
const should_proxy = field.type === '$state' && true; // TODO
82-
const call = /** @type {CallExpression} */ (context.visit(field.value, child_state));
92+
8393
body.push(
84-
b.prop_def(
85-
field.key,
86-
dev
87-
? b.call(
88-
'$.tag',
89-
call,
90-
b.literal(
91-
`${/** @type {ClassDeclaration | ClassExpression} */ (context.path.at(-1))?.id?.name ?? '[class]'}.${field.key.name}`
92-
)
93-
)
94-
: call
95-
),
94+
b.prop_def(field.key, call),
9695

9796
b.method('get', definition.key, [], [b.return(b.call('$.get', member))]),
9897

0 commit comments

Comments
 (0)