src/tinier.js
function updateComponents (address, node, state, diff, bindings, renderResult,
                           relativeAddress, stateCallers, opts) {
  // TODO pull these out to top level
  const updateRecurse = ([ d, s ], k) => {
    // TODO in updateRecurse functions where k can be null, there must be a
    // nicer way to organize things with fewer null checks
    const component = k !== null ? node.component : node
    const newAddress = k !== null ? addressWith(address, k) : address
    const newRelativeAddress = k !== null
          ? addressWith(relativeAddress, k)
          : relativeAddress
    const b = k !== null ? get(bindings, k) : bindings

    // Get binding el
    const lastRenderedEl = get(b, 'data')
    const el = renderResult !== null
          ? renderResult[makeBindingKey(newRelativeAddress)]
          : lastRenderedEl

    // Update the component. If DESTROY, then there will not be a binding.
    const res = updateEl(newAddress, component, s, d.data, lastRenderedEl, el,
                         stateCallers, opts)
    // Fall back on old bindings.
    const nextRenderResult = res.renderResult !== null
          ? res.renderResult
          : null
    // Update children
    const children = updateComponents(newAddress, component.model, s,
                                      d.children, get(b, 'children'),
                                      nextRenderResult, [], stateCallers, opts)
    return tagType(NODE, { data: el, children })
  }

  // TODO pull these out to top level
  const recurse = (n, k) => {
    return updateComponents(addressWith(address, k), n, get(state, k), diff[k],
                            get(bindings, k), renderResult,
                            addressWith(relativeAddress, k), stateCallers, opts)
  }

  return match(node, match_updateComponents, null, diff, state, updateRecurse,
               recurse)
}
function updateComponents (address, node, state, diff, bindings, renderResult,
                           relativeAddress, stateCallers, opts) {
  // TODO pull these out to top level
  const updateRecurse = ([ d, s ], k) => {
    // TODO in updateRecurse functions where k can be null, there must be a
    // nicer way to organize things with fewer null checks
    const component = k !== null ? node.component : node
    const newAddress = k !== null ? addressWith(address, k) : address
    const newRelativeAddress = k !== null
          ? addressWith(relativeAddress, k)
          : relativeAddress
    const b = k !== null ? get(bindings, k) : bindings

    // Get binding el
    const lastRenderedEl = get(b, 'data')
    const el = renderResult !== null
          ? renderResult[makeBindingKey(newRelativeAddress)]
          : lastRenderedEl

    // Update the component. If DESTROY, then there will not be a binding.
    const res = updateEl(newAddress, component, s, d.data, lastRenderedEl, el,
                         stateCallers, opts)
    // Fall back on old bindings.
    const nextRenderResult = res.renderResult !== null
          ? res.renderResult
          : null
    // Update children
    const children = updateComponents(newAddress, component.model, s,
                                      d.children, get(b, 'children'),
                                      nextRenderResult, [], stateCallers, opts)
    return tagType(NODE, { data: el, children })
  }

  // TODO pull these out to top level
  const recurse = (n, k) => {
    return updateComponents(addressWith(address, k), n, get(state, k), diff[k],
                            get(bindings, k), renderResult,
                            addressWith(relativeAddress, k), stateCallers, opts)
  }

  return match(node, match_updateComponents, null, diff, state, updateRecurse,
               recurse)
}
function updateComponents ( address , node , state , diff , bindings , renderResult , relativeAddress , stateCallers , opts ) { // TODO pull these out to top level const updateRecurse = ( [ d , s ] , k ) => { // TODO in updateRecurse functions where k can be null, there must be a // nicer way to organize things with fewer null checks const component = k !== null ? node . component : node const newAddress = k !== null ? addressWith ( address , k ) : address const newRelativeAddress = k !== null ? addressWith ( relativeAddress , k ) : relativeAddress const b = k !== null ? get ( bindings , k ) : bindings // Get binding el const lastRenderedEl = get ( b , 'data' ) const el = renderResult !== null ? renderResult [ makeBindingKey ( newRelativeAddress ) ] : lastRenderedEl // Update the component. If DESTROY, then there will not be a binding. const res = updateEl ( newAddress , component , s , d . data , lastRenderedEl , el , stateCallers , opts ) // Fall back on old bindings. const nextRenderResult = res . renderResult !== null ? res . renderResult : null // Update children const children = updateComponents ( newAddress , component . model , s , d . children , get ( b , 'children' ) , nextRenderResult , [ ] , stateCallers , opts ) return tagType ( NODE , { data : el , children } ) } // TODO pull these out to top level const recurse = ( n , k ) => { return updateComponents ( addressWith ( address , k ) , n , get ( state , k ) , diff [ k ] , get ( bindings , k ) , renderResult , addressWith ( relativeAddress , k ) , stateCallers , opts ) } return match ( node , match_updateComponents , null , diff , state , updateRecurse , recurse ) }
Run create, update, and destroy for component.
@param {Array} address - The location of the component in the state.
@param {Object} node - A model or a node within a model.
@param {Object} diff - The diff object for this component.
@param {Object|null} bindings -
@param {Object|null} renderResult -
@param {Object} stateCallers -
@return {Object}
Run create update and destroy for component .