pull/15962/head
Rich Harris 4 months ago
parent b18407a99b
commit 9f6c4cf848

@ -261,10 +261,10 @@ export function build_component(node, component_name, context, anchor = context.
let expression = /** @type {Expression} */ (context.visit(attribute.expression));
if (attribute.metadata.expression.has_state) {
expression = b.arrow([b.id('$$node')], b.call(expression, b.id('$$node')));
push_prop(b.get(b.call('$.attachment'), [b.return(expression)], true));
} else {
push_prop(b.prop('init', b.call('$.attachment'), expression, true));
}
push_prop(b.prop('get', b.call('$.attachment'), expression, true));
}
}

@ -231,12 +231,18 @@ export function function_declaration(id, params, body) {
}
/**
* @param {string} name
* @param {ESTree.Expression | string} name
* @param {ESTree.Statement[]} body
* @param {boolean} computed
* @returns {ESTree.Property & { value: ESTree.FunctionExpression}}}
*/
export function get(name, body) {
return prop('get', key(name), function_builder(null, [], block(body)));
export function get(name, body, computed = false) {
return prop(
'get',
typeof name === 'string' ? key(name) : name,
function_builder(null, [], block(body)),
computed
);
}
/**

Loading…
Cancel
Save