fix private field tagging, only get `declaration` once

pull/16060/head
ComputerGuy 4 months ago
parent 88c50e58e3
commit 437e6634b0

@ -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 // Replace parts of the class body
for (const definition of node.body) { for (const definition of node.body) {
if (definition.type !== 'PropertyDefinition') { if (definition.type !== 'PropertyDefinition') {
@ -74,19 +78,17 @@ export function ClassBody(node, context) {
? /** @type {CallExpression} */ (context.visit(definition.value, child_state)) ? /** @type {CallExpression} */ (context.visit(definition.value, child_state))
: undefined; : 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)); body.push(b.prop_def(definition.key, value));
} else if (field.node === definition) { } else if (field.node === definition) {
let call = /** @type {CallExpression} */ (context.visit(field.value, child_state)); let call = /** @type {CallExpression} */ (context.visit(field.value, child_state));
if (dev) { if (dev) {
const declaration = /** @type {ClassDeclaration | ClassExpression} */ (
get_parent(context.path, -1)
);
call = b.call('$.tag', call, b.literal(`${declaration.id?.name ?? '[class]'}.${name}`)); call = b.call('$.tag', call, b.literal(`${declaration.id?.name ?? '[class]'}.${name}`));
} }
const member = b.member(b.this, field.key); const member = b.member(b.this, field.key);
const should_proxy = field.type === '$state' && true; // TODO const should_proxy = field.type === '$state' && true; // TODO

Loading…
Cancel
Save