Change how some child objects are stored on RB.DiffViewerPage.
Review Request #9163 — Created Aug. 31, 2017 and submitted
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 ofparse()
to feed in data. That
required also modifyingset()
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 inparse()
. We
useModel.constructor()
instead ofModel.initialize()
to do this,
since the former will run beforeparse()
andinitialize()
, 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.