Update base objects to use static and merge for configurable attributes.
Review Request #12909 — Created March 22, 2023 and submitted — Latest diff uploaded
Starting in Spina 2,
BaseModel
,BaseView
, andBaseCollection
's
configurable attributes are now defined asstatic
, allowing them to be
accessed outside of instances. This is important for subclasses.These make use of the new
prototypeAttrs
option, which ensures they'll
be accessible on the prototype, allowing Backbone to behave as normal
and for instances to continue accessing usingthis
.Types for both the
static
and instance/prototype versions are set on
these base classes. Sincestatic
is incompatible with generics, we use
the most base type for these there, but the ones on the prototype are
typed as expected. Subclasses may still define types for their versions.Some attributes (
events
,modelEvents
, anddefaults
) are also set
up to auto-merge between parents/subclasses. This means that subclasses
no longer have to manually call_.defaults
or_.extends
, passing in
the parent class's attribute (but at the same time, it won't hurt if
they still do). This will keep things more maintainable going forward.
Porting existing code in Review Board to set the appropriate attributes
asstatic
, and verified that instances and subclasses could properly
access and extend these.