From 437e6634b0dd41b9f522d851b5ab59381b20c514 Mon Sep 17 00:00:00 2001 From: ComputerGuy <63362464+Ocean-OS@users.noreply.github.com> Date: Mon, 2 Jun 2025 16:57:29 -0700 Subject: [PATCH] fix private field tagging, only get `declaration` once --- .../3-transform/client/visitors/ClassBody.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/ClassBody.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/ClassBody.js index af14821531..e78a8824dd 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/ClassBody.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/ClassBody.js @@ -52,6 +52,10 @@ export function ClassBody(node, context) { } } + const declaration = /** @type {ClassDeclaration | ClassExpression} */ ( + get_parent(context.path, -1) + ); + // Replace parts of the class body for (const definition of node.body) { if (definition.type !== 'PropertyDefinition') { @@ -74,19 +78,17 @@ export function ClassBody(node, context) { ? /** @type {CallExpression} */ (context.visit(definition.value, child_state)) : undefined; - if (dev) value = b.call('$.tag', value, b.literal(name)); + if (dev) { + value = b.call('$.tag', value, b.literal(`${declaration.id?.name ?? '[class]'}.${name}`)); + } + body.push(b.prop_def(definition.key, value)); } else if (field.node === definition) { let call = /** @type {CallExpression} */ (context.visit(field.value, child_state)); if (dev) { - const declaration = /** @type {ClassDeclaration | ClassExpression} */ ( - get_parent(context.path, -1) - ); - call = b.call('$.tag', call, b.literal(`${declaration.id?.name ?? '[class]'}.${name}`)); } - const member = b.member(b.this, field.key); const should_proxy = field.type === '$state' && true; // TODO