pull/8386/head
Simon H 4 years ago committed by GitHub
parent 3eb16eba24
commit 8b9db8226f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -99,11 +99,11 @@ class AwaitBlockBranch extends Wrapper {
render_get_context() { render_get_context() {
const props = this.is_destructured ? this.value_contexts.map(prop => { const props = this.is_destructured ? this.value_contexts.map(prop => {
const to_ctx = name => this.renderer.reference(name);
if (prop.type === 'ComputedProperty') { if (prop.type === 'ComputedProperty') {
const expression = new Expression(this.renderer.component, this.node, this.has_consts(this.node) ? this.node.scope : null, prop.key); const expression = new Expression(this.renderer.component, this.node, this.has_consts(this.node) ? this.node.scope : null, prop.key);
return b`const ${prop.property_name} = ${expression.manipulate(this.block, '#ctx')};`; return b`const ${prop.property_name} = ${expression.manipulate(this.block, '#ctx')};`;
} else { } else {
const to_ctx = name => this.renderer.reference(name);
return b`#ctx[${this.block.renderer.context_lookup.get(prop.key.name).index}] = ${prop.default_modifier(prop.modifier(x`#ctx[${this.value_index}]`), to_ctx)};`; return b`#ctx[${this.block.renderer.context_lookup.get(prop.key.name).index}] = ${prop.default_modifier(prop.modifier(x`#ctx[${this.value_index}]`), to_ctx)};`;
} }
}) : null; }) : null;

@ -365,9 +365,8 @@ export default class EachBlockWrapper extends Wrapper {
} }
this.context_props = this.node.contexts.map(prop => { this.context_props = this.node.contexts.map(prop => {
const to_ctx = (name: string) => renderer.context_lookup.has(name) ? x`child_ctx[${renderer.context_lookup.get(name).index}]` : { type: 'Identifier', name } as Node;
if (prop.type === 'DestructuredVariable') { if (prop.type === 'DestructuredVariable') {
const to_ctx = (name: string) => renderer.context_lookup.has(name) ? x`child_ctx[${renderer.context_lookup.get(name).index}]` : { type: 'Identifier', name } as Node;
return b`child_ctx[${renderer.context_lookup.get(prop.key.name).index}] = ${prop.default_modifier(prop.modifier(x`list[i]`), to_ctx)};`; return b`child_ctx[${renderer.context_lookup.get(prop.key.name).index}] = ${prop.default_modifier(prop.modifier(x`list[i]`), to_ctx)};`;
} else { } else {
const expression = new Expression(this.renderer.component, this.node, this.node.scope, prop.key); const expression = new Expression(this.renderer.component, this.node, this.node.scope, prop.key);

Loading…
Cancel
Save