Skip to content

Commit 437e663

Browse files
committed
fix private field tagging, only get declaration once
1 parent 88c50e5 commit 437e663

File tree

1 file changed

+8
-6
lines changed
  • packages/svelte/src/compiler/phases/3-transform/client/visitors

1 file changed

+8
-6
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ export function ClassBody(node, context) {
5252
}
5353
}
5454

55+
const declaration = /** @type {ClassDeclaration | ClassExpression} */ (
56+
get_parent(context.path, -1)
57+
);
58+
5559
// Replace parts of the class body
5660
for (const definition of node.body) {
5761
if (definition.type !== 'PropertyDefinition') {
@@ -74,19 +78,17 @@ export function ClassBody(node, context) {
7478
? /** @type {CallExpression} */ (context.visit(definition.value, child_state))
7579
: undefined;
7680

77-
if (dev) value = b.call('$.tag', value, b.literal(name));
81+
if (dev) {
82+
value = b.call('$.tag', value, b.literal(`${declaration.id?.name ?? '[class]'}.${name}`));
83+
}
84+
7885
body.push(b.prop_def(definition.key, value));
7986
} else if (field.node === definition) {
8087
let call = /** @type {CallExpression} */ (context.visit(field.value, child_state));
8188

8289
if (dev) {
83-
const declaration = /** @type {ClassDeclaration | ClassExpression} */ (
84-
get_parent(context.path, -1)
85-
);
86-
8790
call = b.call('$.tag', call, b.literal(`${declaration.id?.name ?? '[class]'}.${name}`));
8891
}
89-
9092
const member = b.member(b.this, field.key);
9193
const should_proxy = field.type === '$state' && true; // TODO
9294

0 commit comments

Comments
 (0)