Fix defaults() to always be static.
Review Request #13517 — Created Feb. 1, 2024 and submitted
We had a number of classes where
defaults
was not properly defined as
static
. This broke when updating to the newerspina
that fixes
prototypeAttrs
inheritance.
- Ran js-tests.
- Audited the codebase for this and other inherited attributes that
needed to be static.
-
The new Spina changes up for review correct the problem that impacted the tests, which was that order of automerge and prototype attr operations was incorrect, causing state to be overridden.
I've been thinking about what the most correct thing is for these sorts of methods going forward. At first glance, some of these may appear to be all about the construction of objects (such as
defaults()
orevents()
), but most are more instance-bound, and even those two aforementioned ones could refer to state from construction.I think the right way going forward is to keep these as prototype-bound methods. But I also think that we should move away from Backbone's duality of function/value for these, when it comes to actually implementing them.
I'm playing around with some ideas there, but they basically center around using the existing attributes as hard-coded values, and having entirely new methods to use when you want to dynamically build a value (e.g.
buildDefaults()
andbuildEvents()
).And then utility methods for getting the right computed value (e.g.,
getDefaults()
andgetEvents()
).This would mean we have fewer hacks to think about to get values where we need them and typed correctly.