gmac/backbone.epoxy — pull request #33 by nfm (2013-08-22 06:22:22+00:00)
Title: Ensure viewMap doesn't leak from collection binding to first model instance

This fixes a bug where a view collection binding, whose child views had model bindings, would trigger events inappropriately on the collection when the model changed. As a result, the collection binding set() function would receive the model, and assume it was a remove event, even though the model had simply changed an attribute.

I've added a test case that reproduces the behaviour. Basically, when you change the model's attribute, the collection view for it is inappropriately removed from the DOM.

The viewMap variable was leaking from the collection binding to the first model in the collection, and addSourceToViewContext was inappropriately reusing events from the collection for the model.

This only occurred if the parent view was initialized with a non-empty collection. In the other test cases, where the collection is initially populated by resetting it, the bug was avoided.