Add options for installing and merging class attributes.
Review Request #12907 — Created March 22, 2023 and submitted
This introduces some important new options for Spina, designed to fix
problems encountered as we ported more class hierarchies from Backbone
ES6 classes have static attributes (which must be accessed on the class
constructor name) and instance attributes (which are only created when a
class is instantiated). What's missing are attributes that live on the
protocol (more akin to Python class attributes), which are what Backbone
The recommendation is now to use static attributes. Spina now provides a
prototypeAttrsoption for classes that are used to specify static
defaults,tagName`, etc.) that must be made
available on the prototype. On class preparation, getters/setters will
be injected on the prototype to wrap the static attributes.
To aid in keeping attributes manageable, there's also a new
automergedAttrsoption that can be defined on a class. This is used by
the class and any subclasses to merge together attributes containing
keys. For example, if a parent class and subclass both define
and this is in some base class's
automergedAttrs, then the two will be
combined, reducing the chances of missing entries.
skipAutomergedAttrscan be used by a subclass to turn this behavior
off for select attributes, or all attributes.
These will be enabled soon for the built-in classes, and consumers can
use these to help transition to static-only attributes and to refine
Tested these new options in Review Board when converting classes to
Spina. Verified that specified attributes would merge and were
accessible on the prototype.