deconflict `value` argument in component bindings (#2395)

pull/2414/head
Conduitry 6 years ago
parent 3f97558533
commit a710b1311c

@ -327,13 +327,14 @@ export default class InlineComponentWrapper extends Wrapper {
contextual_dependencies.push(object, property);
}
const args = ['value'];
const value = block.get_unique_name('value');
const args = [value];
if (contextual_dependencies.length > 0) {
args.push(`{ ${contextual_dependencies.join(', ')} }`);
block.builders.init.add_block(deindent`
function ${name}(value) {
if (ctx.${name}.call(null, value, ctx)) {
function ${name}(${value}) {
if (ctx.${name}.call(null, ${value}, ctx)) {
${updating} = true;
}
}
@ -342,8 +343,8 @@ export default class InlineComponentWrapper extends Wrapper {
block.maintain_context = true; // TODO put this somewhere more logical
} else {
block.builders.init.add_block(deindent`
function ${name}(value) {
if (ctx.${name}.call(null, value)) {
function ${name}(${value}) {
if (ctx.${name}.call(null, ${value})) {
${updating} = true;
}
}
@ -352,7 +353,7 @@ export default class InlineComponentWrapper extends Wrapper {
const body = deindent`
function ${name}(${args.join(', ')}) {
${lhs} = value;
${lhs} = ${value};
return ${component.invalidate(dependencies[0])}
}
`;

Loading…
Cancel
Save