Add an extend() method to all Spina classes.

Review Request #12908 — Created March 22, 2023 and submitted

Information

Spina
master

Reviewers

This introduces an extend() method on Spina classes that behaves like
the Backbone extend() methods. This can take prototype properties and
static properties and will construct a new Spina-compatible subclass
that behaves just like an older-style prototype-based Backbone subclass.

With this, base classes can be converted incrementally to ES6 classes,
without breaking any legacy subclasses or altering any behavior.

The implementation is pretty straightforward. The biggest problems to
solve weren't class construction, but rather the differences between
legacy classes (which use prototype-based attributes) and ES6 classes
(which have static attributes or instance attributes, but no prototype
attributes). Those issues have been solved by the recent option changes,
allowing extend() to be able to work.

This also introduces a __super__ attribute on instances of the
classes, which is needed for compatibility with Backbone's __super__
attribute. This can help properly determine parent classes for legacy
class instances.

Verified the Review Board test suite passed when using this along with
other Spina 2 changes and converting some central base classes to
ES6 classes.

Summary ID
Add an extend() method to all Spina classes.
This introduces an `extend()` method on Spina classes that behaves like the Backbone `extend()` methods. This can take prototype properties and static properties and will construct a new Spina-compatible subclass that behaves just like an older-style prototype-based Backbone subclass. With this, base classes can be converted incrementally to ES6 classes, without breaking any legacy subclasses or altering any behavior. The implementation is pretty straightforward. The biggest problems to solve weren't class construction, but rather the differences between legacy classes (which use prototype-based attributes) and ES6 classes (which have static attributes or instance attributes, but no prototype attributes). Those issues have been solved by the recent option changes, allowing `extend()` to be able to work. This also introduces a `__super__` attribute on instances of the classes, which is needed for compatibility with Backbone's `__super__` attribute. This can help properly determine parent classes for legacy class instances.
fdd5b151abdb243eddf56e3bf70cb2d5595ee5e1
david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to master (224c2f1)
Loading...