chaplinjs/chaplin — pull request #542 by molily (2013-04-13 03:06:58+00:00)
Title: Add Collection#set() support to CollectionView

Small code change and spec additions are necessary.

Revamp the complete CollectionView spec, structure it with `describe`, reorder the parts. Make `collection`/`collectionView` setup explicit so there are no `dispose()` calls right at the beginning of examples.

Side note: What was wrong with `options.index`? This is a just relict of our old `Collection#update` method. Backbone does not add the `index` option to `add` events. Okay, but why did that cause a problem? The current `Collection#set` implementation may call `Collection#remove` which adds `index` to the passed options without making a copy of it. Long story short, there might be an `index` option present even when it’s an `add` event. … WTF. Took me a while to figure that out. I’m glad we added all those `options = _.clone(options)` calls some time ago.