montagejs/montage — pull request #1214 by kriskowal (2013-07-10 04:58:43+00:00)
Title: Fix repetition child component management

Adding and removing child components when the model changes is too soon
because some of the iterations may not have been fully initialized and
won't have childComponents at that time.

Adding and removing childComponents when drawing a repetition is too
late because the component tree is used to determine whether the
repetition or any of its children are eligible to be included in the
draw cycle.

The solution is to synchronize the components some time in between. We
establish a change listener for the FRB expression
"_childComponents.defined() && index.defined()": the conditions under
which it is both possible *and* desirable for the iteration's child
components to be in the comopnent tree model. The first condition
satisfies the initialization of the iteration. The second condition
satisfies that the iteration is supposed to be in use and on the DOM
after the next draw. We watch for changes to the combined condition and
add and remove child components accordingly.

This also brings the repetition test up to passing with most of the
original cases enabled.

This also updates the JSDoc to use Markdown instead of HTML for code
fragments.