[!] Base and BaseCore now add all ATTRS definitions, across the hierarchy,
in a single shot. Prior to this change, they used to be added a class
at a time.
That is, for Foo extends Bar, the order of operations used to be:
- Add Bar ATTRS
- Call Bar initializer
- Add Foo ATTRS
- Call Foo initializer
Now it is:
- Add Foo and Bar's ATTRS together
- Call Bar initializer
- Call Foo initializer
This change fixes issues encountered in real-world code where setters,
getters and valueFns in superclass ATTRS, overidden in a subclass,
wouldn't be able to access the subclass' attributes.
However as a result of this change, there are a couple of areas,
mentioned below, which may require component developers (especially
Extension developers) to update their implementations. These are
mentioned below:
A. There may potentially be setters/getters/valueFns in Foo, which
expected Bar's initializer to have been executed already.
This is expected to be rare, and if required, the _preAddAttrs()
hook described in the API Documentation, can be used to jump in before
attributes are added.
B. Older Extensions may need to move code from their Constructors, to
initializers.
To align with the above change, Base and BaseCore will now call all
Extension constructors before any attributes are added, to address issues
where attribute configurations required Extension constructors to have run.
Extensions created before initializer support for Extensions was added to
Base, may have code in their constructors which accesses attributes from a
superclass.
Such code would need to be moved to an initializer method on the Extension,
which is likely the proper place for it. YUI's WidgetPosition and other
extensions based on it, needed to do this for example.
Although this scenario is expected to be more common, the upgrade requirement
was simple enough to warrant us pursuing this change so that the attribute
setup flow was cleaner moving foward.
See the Base and BaseCore API docs and the base-core unit tests for more
details.