|
|
@ -156,7 +156,7 @@ export default class Component extends Node {
|
|
|
|
|
|
|
|
|
|
|
|
let setFromChild;
|
|
|
|
let setFromChild;
|
|
|
|
|
|
|
|
|
|
|
|
if (!isStoreProp && block.contexts.has(key)) {
|
|
|
|
if (block.contexts.has(key)) {
|
|
|
|
const computed = isComputed(binding.value);
|
|
|
|
const computed = isComputed(binding.value);
|
|
|
|
const tail = binding.value.type === 'MemberExpression' ? getTailSnippet(binding.value) : '';
|
|
|
|
const tail = binding.value.type === 'MemberExpression' ? getTailSnippet(binding.value) : '';
|
|
|
|
|
|
|
|
|
|
|
@ -171,7 +171,8 @@ export default class Component extends Node {
|
|
|
|
`;
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
else if (binding.value.type === 'MemberExpression') {
|
|
|
|
else {
|
|
|
|
|
|
|
|
if (binding.value.type === 'MemberExpression') {
|
|
|
|
setFromChild = deindent`
|
|
|
|
setFromChild = deindent`
|
|
|
|
${binding.snippet} = childState.${binding.name};
|
|
|
|
${binding.snippet} = childState.${binding.name};
|
|
|
|
${newState}.${key} = state.${key};
|
|
|
|
${newState}.${key} = state.${key};
|
|
|
@ -181,6 +182,7 @@ export default class Component extends Node {
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
setFromChild = `${newState}.${key} = childState.${binding.name};`;
|
|
|
|
setFromChild = `${newState}.${key} = childState.${binding.name};`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
statements.push(deindent`
|
|
|
|
statements.push(deindent`
|
|
|
|
if (${binding.prop} in ${binding.obj}) {
|
|
|
|
if (${binding.prop} in ${binding.obj}) {
|
|
|
@ -223,32 +225,25 @@ export default class Component extends Node {
|
|
|
|
var ${initialisers};
|
|
|
|
var ${initialisers};
|
|
|
|
${!setStoreFromChildOnChange.isEmpty() && deindent`
|
|
|
|
${!setStoreFromChildOnChange.isEmpty() && deindent`
|
|
|
|
${setStoreFromChildOnChange}
|
|
|
|
${setStoreFromChildOnChange}
|
|
|
|
${name_updating} = @assign({}, changed);
|
|
|
|
|
|
|
|
#component.store.set(newStoreState);
|
|
|
|
#component.store.set(newStoreState);
|
|
|
|
`}
|
|
|
|
`}
|
|
|
|
${!setParentFromChildOnChange.isEmpty() && deindent`
|
|
|
|
${!setParentFromChildOnChange.isEmpty() && deindent`
|
|
|
|
${setParentFromChildOnChange}
|
|
|
|
${setParentFromChildOnChange}
|
|
|
|
${name_updating} = @assign({}, changed);
|
|
|
|
|
|
|
|
#component._set(newState);
|
|
|
|
#component._set(newState);
|
|
|
|
`}
|
|
|
|
`}
|
|
|
|
${name_updating} = {};
|
|
|
|
${name_updating} = {};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`);
|
|
|
|
`);
|
|
|
|
|
|
|
|
|
|
|
|
// TODO can `!childState` ever be true?
|
|
|
|
|
|
|
|
beforecreate = deindent`
|
|
|
|
beforecreate = deindent`
|
|
|
|
#component.root._beforecreate.push(function() {
|
|
|
|
#component.root._beforecreate.push(function() {
|
|
|
|
var childState = ${name}.get(), ${initialisers};
|
|
|
|
var childState = ${name}.get(), ${initialisers};
|
|
|
|
if (!childState) return;
|
|
|
|
|
|
|
|
${setParentFromChildOnInit}
|
|
|
|
|
|
|
|
${!setStoreFromChildOnInit.isEmpty() && deindent`
|
|
|
|
${!setStoreFromChildOnInit.isEmpty() && deindent`
|
|
|
|
${setStoreFromChildOnInit}
|
|
|
|
${setStoreFromChildOnInit}
|
|
|
|
${name_updating} = { ${bindings.map((binding: Binding) => `${binding.name}: true`).join(', ')} };
|
|
|
|
|
|
|
|
#component.store.set(newStoreState);
|
|
|
|
#component.store.set(newStoreState);
|
|
|
|
`}
|
|
|
|
`}
|
|
|
|
${!setParentFromChildOnInit.isEmpty() && deindent`
|
|
|
|
${!setParentFromChildOnInit.isEmpty() && deindent`
|
|
|
|
${setParentFromChildOnInit}
|
|
|
|
${setParentFromChildOnInit}
|
|
|
|
${name_updating} = { ${bindings.map((binding: Binding) => `${binding.name}: true`).join(', ')} };
|
|
|
|
|
|
|
|
#component._set(newState);
|
|
|
|
#component._set(newState);
|
|
|
|
`}
|
|
|
|
`}
|
|
|
|
${name_updating} = {};
|
|
|
|
${name_updating} = {};
|
|
|
|