Livefyre/view — pull request #1 by gobengo (2013-12-16 21:07:46+00:00)
Title: EventMap (incl #extended) and View#delegateEvents on #setElement

View.prototype.events is now defined and is an instance of `view/event-map`. EventMaps are almost POJO's, but with an `extended(extension1, extension2, ...)` method that returns a new EventMap with all the methods of the original, and also the methods defined in the objects passed to `.extended.`

This is useful for View subclasses for two reasons
* You don't have to require or write your own `extends` function in every View subclass, you can just do

```js
ChildView.prototype.events = ParentView.prototype.events.extended({
'click .child': function () {}
});
```

* You may be saying. "Whatever, I can just use `$.extend`". Except you probably don't want that. `$.extend` copies prototype properties alongwith ownProperties, which can cause problems.

This Pull also makes sure that View.prototype.setElement delegatesEvents to the new element. And if there was a previous element, those events are undelegated. This makes it fine and easy to change the Element that a View is controlling, which is useful for constructing subViews on construction, but waiting until .render to call .setElement on them.