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

Loading…
Cancel
Save