emberjs/ember.js — pull request #3254 by eviltrout (2013-08-29 20:55:33+00:00)
Title: Fixes to GroupedEach

The `GroupedEach` functionality is mostly hidden in Ember right now, but we are using it on Discourse for performance reasons. I discovered some issues within the `GroupedEach` helper in Ember and these commits address their behaviour, complete with tests.

1. If you created a `GroupedEach` with on a variable that's undefined, you would get a big nasty error. The first commit fixes that by checking that content is there before rendering and setting up observers.

2. If you changed the content of a `GroupedEach` right before it was destroyed, Ember would complain about "You can't call rerender on a view being destroyed". This is because `rerenderContainingView` was scheduling a render in the future, and a call to destroy could be made in the meantime. We actually encountered this on Discourse.

The fix was to track that an object was deleted in case a rerender was scheduled in the future after the `destroy` was called.