documentcloud/backbone — pull request #801 by gravof (2011-12-20 09:05:37+00:00)
Title: Allow previous and alike methods to be called outside change event

Currently `previous()` and `previousAttributes()` are only supposed to be used during a change event, but they do make sense outside the event. In order not to break `hasChanged()` and `changedAttributes`, I added another private property '_attributes'.

This is how `attributes`, `_attributes`, `_previousAttributes` will change in the course of the change event:

attrs _attrs _prevAttrs
new k:1 k: 1 k: 1 undefined
set k:2 k: 2 k: 1 undefined
(after set) k: 2 k: 2 k: 1
set k:3 k: 3 k: 2 k: 1
(after set) k: 3 k: 3 k: 2

`hasChanged()` and `changedAttributes` compare `attributes` to `_attributes`. `previous()` and `previousAttributes()` return `_attributes` during the change event, and `_previousAttributes` otherwise.

So now `previous()` behaves differently outside the change event than it does in 0.5.3, but since the doc says it should only be used in a change event, I guess it should be safe to make this change.

This is actually my second try to fix #373