From f328f219e56f87459f3193fbdeb5ab132211d0a5 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Sun, 14 Apr 2019 12:01:24 -0400 Subject: [PATCH] deconflict `value` argument in component bindings (#2395) --- .../render-dom/wrappers/InlineComponent/index.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/compile/render-dom/wrappers/InlineComponent/index.ts b/src/compile/render-dom/wrappers/InlineComponent/index.ts index bc13014a29..1fae0aedcc 100644 --- a/src/compile/render-dom/wrappers/InlineComponent/index.ts +++ b/src/compile/render-dom/wrappers/InlineComponent/index.ts @@ -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])} } `;