emberjs/ember.js — pull request #2415 by kratob (2013-04-08 11:13:36+00:00)
Title: Close #2403 - Removing last item in CollectionView triggers removal of metamorph views that are not in the DOM

This fixes issue #2403.

There had already been a PR (#2133) which hasn't been merged yet. This is an alternative fix with a test case that does not depend on handlebars.

It's possible that the `CollectionView` is not actually the right place to fix this (other parts of the code depend on views to propagate the `removedFromDOM` to their children), but since the `CollectionView` does something special here (with the .empty() call), I think this is okay.

The reason why it is not propagated through the regular `view.destroy` is that the code only calls `.destroy()` on the innermost nested view, but not on its parent (which happens in `view.clearRenderedChildren`).