Fix issues inheriting Spina options for attribute promoting/merging.

Review Request #13528 — Created Feb. 6, 2024 and submitted

Information

Spina
master

Reviewers

A big feature in Spina 2.1 was inheritance of the Spina options for
prototypeAttrs and automergeAttrs. The idea was to fix the issue
where, if you don't keep re-introducing the same properties in each
subclass, the options would be lost for their subclasses. We never
released 2.1 because this ended up causing significant unit test
regressions in Review Board.

There were a a few primary reasons it didn't work as expected:

  1. automergeAttrs was processed before prototypeAttrs, which meant
    that any attributes defined as static would override any attributes
    that were merged.

  2. Functions (such as defaults() or events()) could not be
    auto-merged. It would try, but would fail.

  3. Auto-merging could fail to see prototype attributes on the new class,
    instead prioritizing parent classes.

  4. State wouldn't always be copied back to the prototypes after merging.

This change alters the ordering, implements some more careful management
of the state, handles function merging, and carefully accesses the
correct attributes to auto-merge on the new class.

Unit tests pass in Review Board and Spina.

Summary ID
Fix issues inheriting Spina options for attribute promoting/merging.
A big feature in Spina 2.1 was inheritance of the Spina options for `prototypeAttrs` and `automergeAttrs`. The idea was to fix the issue where, if you don't keep re-introducing the same properties in each subclass, the options would be lost for their subclasses. We never released 2.1 because this ended up causing significant unit test regressions in Review Board. There were a a few primary reasons it didn't work as expected: 1. `automergeAttrs` was processed before `prototypeAttrs`, which meant that any attributes defined as static would override any attributes that were merged. 2. Functions (such as `defaults()` or `events()`) could not be auto-merged. It would try, but would fail. 3. Auto-merging could fail to see prototype attributes on the new class, instead prioritizing parent classes. 4. State wouldn't always be copied back to the prototypes after merging. This change alters the ordering, implements some more careful management of the state, handles function merging, and carefully accesses the correct attributes to auto-merge on the new class.
2266f14ddd9ea36cad42139cf0d496bae1338769
Description From Last Updated

Small nit but you could remove the "like" before "object-like".

maubinmaubin
david
  1. Ship It!
  2. 
      
maubin
  1. 
      
  2. src/objects.ts (Diff revision 1)
     
     
    Show all issues

    Small nit but you could remove the "like" before "object-like".

  3. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to master (b9ae9cd)
Loading...