BlueSpire/Durandal — pull request #475 by ropez (2014-04-08 12:56:23+00:00)
Title: Abort composition when the context is changed during activation

This patch changes what happens if composition.compose is called, while
waiting for the activate callback to complete for an obsolete
composition context on the same parent element. The obsolete context is
ignored, and only the current (correct) context is applied.

Unfortunately, there's no way to abort the activate call for the
aborted composition, so we need to keep track of the state, so that we
can ignore the deferred callback on the obsolete state.

One unfortunate side-effect is that the compositionComplete callback is
called on both context, and only after the activate hooks for both
contexts are complete. So there might be a time gap after the activate
hook for the final correct state is finished, and the
compositionComplete is called.

(view patch with -w, --ignore-all-space)