pull/3079/head
Conduitry 6 years ago
parent a6771716ad
commit 22fd9c18f1

@ -277,18 +277,16 @@ export default class InlineComponentWrapper extends Wrapper {
} }
const contextual_dependencies = [...binding.expression.contextual_dependencies]; const contextual_dependencies = [...binding.expression.contextual_dependencies];
const contextual_params = contextual_dependencies.length > 0 ? `, ${contextual_dependencies.join(', ')}` : '';
const call_site_contextual_params = contextual_dependencies.length > 0 ? `, ${contextual_dependencies.map(name => `ctx.${name}`).join(', ')}` : '';
component.partly_hoisted.push(deindent` component.partly_hoisted.push(deindent`
function ${fn}($$component${contextual_params}) { function ${fn}(${['$$component', ...contextual_dependencies].join(', ')}) {
${lhs} = $$component; ${lhs} = $$component;
${object && component.invalidate(object)} ${object && component.invalidate(object)}
} }
`); `);
block.builders.destroy.add_line(`ctx.${fn}(null);`); block.builders.destroy.add_line(`ctx.${fn}(null);`);
return `@add_binding_callback(() => ctx.${fn}(${this.var}${call_site_contextual_params}));`; return `@add_binding_callback(() => ctx.${fn}(${[this.var, ...contextual_dependencies.map(name => `ctx.${name}`)].join(', ')}));`;
} }
const name = component.get_unique_name(`${this.var}_${binding.name}_binding`); const name = component.get_unique_name(`${this.var}_${binding.name}_binding`);

@ -29,4 +29,3 @@ export default function flatten_reference(node: Node) {
return { name, nodes, parts, keypath: `${name}[✂${prop_start}-${prop_end}✂]` }; return { name, nodes, parts, keypath: `${name}[✂${prop_start}-${prop_end}✂]` };
} }
Loading…
Cancel
Save