Change how some child objects are stored on RB.DiffViewerPage.

Review Request #9163 — Created Aug. 31, 2017 and submitted — Latest diff uploaded

Information

Review Board
release-3.0.x
b61fc1e...

Reviewers

The RB.DiffViewerPage model had a few helper child objects that were
responsible for different aspects of the page. These were stored as
attributes, in order to allow usage of parse() to feed in data. That
required also modifying set() to be able to update the existing
instances based on the attributes of newly-constructed ones from
parse(), and made working with the objects a bit awkward.

This change switches these objects to being constructed when creating
an instance of the model, and then filling the objects in parse(). We
use Model.constructor() instead of Model.initialize() to do this,
since the former will run before parse() and initialize(), allowing
us to create those objects. This is recommended in the Backbone
documentation for this use case.

Unit tests pass.

Tested loading diffs, switching revisions (single revisions and
interdiff ranges), and switching pages.

    Loading...