From b3382aa7a3efb0c368801a969d384f9afb480c2e Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sat, 10 Feb 2018 20:28:01 -0500 Subject: [PATCH] combine component binding init/update --- src/generators/nodes/Component.ts | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/src/generators/nodes/Component.ts b/src/generators/nodes/Component.ts index 4607789316..59647d2c5a 100644 --- a/src/generators/nodes/Component.ts +++ b/src/generators/nodes/Component.ts @@ -138,10 +138,7 @@ export default class Component extends Node { statements.push(`var ${name_initial_data} = ${initialPropString};`); const setParentFromChildOnChange = new CodeBuilder(); - const setParentFromChildOnInit = new CodeBuilder(); - const setStoreFromChildOnChange = new CodeBuilder(); - const setStoreFromChildOnInit = new CodeBuilder(); bindings.forEach((binding: Binding) => { let { name: key } = getObject(binding.value); @@ -196,11 +193,6 @@ export default class Component extends Node { setFromChild ); - (isStoreProp ? setStoreFromChildOnInit : setParentFromChildOnInit).addConditional( - `!${name_updating}.${binding.name}`, - setFromChild - ); - // TODO could binding.dependencies.length ever be 0? if (binding.dependencies.length) { updates.push(deindent` @@ -237,16 +229,7 @@ export default class Component extends Node { beforecreate = deindent` #component.root._beforecreate.push(function() { - var childState = ${name}.get(), ${initialisers}; - ${!setStoreFromChildOnInit.isEmpty() && deindent` - ${setStoreFromChildOnInit} - #component.store.set(newStoreState); - `} - ${!setParentFromChildOnInit.isEmpty() && deindent` - ${setParentFromChildOnInit} - #component._set(newState); - `} - ${name_updating} = {}; + ${name}._bind({ ${bindings.map(b => `${b.name}: 1`).join(', ')} }, ${name}.get()); }); `; } else if (initialProps.length) {