Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Give BaseCore and Base their own `_buildCfg` objects.

  • Loading branch information...
commit a4cc1a7ecd5749b55c1576e5aeedaeeea9f19ef9 1 parent bfcf08c
@ericf authored
Showing with 53 additions and 32 deletions.
  1. +53 −32 src/base/js/BaseBuild.js
View
85 src/base/js/BaseBuild.js
@@ -8,16 +8,42 @@
* @for Base
*/
var BaseCore = Y.BaseCore,
- Base = Y.Base,
- L = Y.Lang,
+ Base = Y.Base,
+ L = Y.Lang,
+
INITIALIZER = "initializer",
- DESTRUCTOR = "destructor",
- build,
- arrayAggregator = function (prop, r, s) {
- if (s[prop]) {
- r[prop] = (r[prop] || []).concat(s[prop]);
+ DESTRUCTOR = "destructor",
+ AGGREGATES = ["_PLUG", "_UNPLUG"],
+
+ build;
+
+ // Utility function used in `_buildCfg` to aggregate array values into a new
+ // array from the sender constructor to the reciver constructor.
+ function arrayAggregator(prop, r, s) {
+ if (s[prop]) {
+ r[prop] = (r[prop] || []).concat(s[prop]);
+ }
+ }
+
+ // Utility function used in `_buildCfg` to aggregate ATTRS configs from one
+ // the sender constructor to the reciver constructor.
+ function attrsAggregator(prop, r, s) {
+ var sAttrs, rAttrs, a;
+
+ r.ATTRS = r.ATTRS || {};
+
+ if (s.ATTRS) {
+ sAttrs = s.ATTRS;
+ rAttrs = r.ATTRS;
+
+ for (a in sAttrs) {
+ if (sAttrs.hasOwnProperty(a)) {
+ rAttrs[a] = rAttrs[a] || {};
+ Y.mix(rAttrs[a], sAttrs[a], true);
+ }
}
- };
+ }
+ }
Base._build = function(name, main, extensions, px, sx, cfg) {
@@ -382,9 +408,9 @@
/**
* The build configuration for the Base class.
*
- * Defines the static fields which need to be aggregated
- * when the Base class is used as the main class passed to
- * the <a href="#method_Base.build">Base.build</a> method.
+ * Defines the static fields which need to be aggregated when the Base class
+ * is used as the main class passed to the
+ * <a href="#method_Base.build">Base.build</a> method.
*
* @property _buildCfg
* @type Object
@@ -392,28 +418,23 @@
* @final
* @private
*/
- Base._buildCfg = BaseCore._buildCfg = {
- custom : {
- ATTRS : function(prop, r, s) {
- r.ATTRS = r.ATTRS || {};
-
- if (s.ATTRS) {
-
- var sAttrs = s.ATTRS,
- rAttrs = r.ATTRS,
- a;
+ BaseCore._buildCfg = {
+ custom: {
+ ATTRS : attrsAggregator,
+ _ATTR_CFG : arrayAggregator,
+ _NON_ATTRS_CFG: arrayAggregator
+ },
- for (a in sAttrs) {
- if (sAttrs.hasOwnProperty(a)) {
- rAttrs[a] = rAttrs[a] || {};
- Y.mix(rAttrs[a], sAttrs[a], true);
- }
- }
- }
- },
+ aggregates: AGGREGATES.concat()
+ };
- _ATTR_CFG : arrayAggregator,
- _NON_ATTRS_CFG : arrayAggregator
+ // Makes sure Base and BaseCore use separate `_buildCfg` objects.
+ Base._buildCfg = {
+ custom: {
+ ATTRS : attrsAggregator,
+ _ATTR_CFG : arrayAggregator,
+ _NON_ATTRS_CFG: arrayAggregator
},
- aggregates : ["_PLUG", "_UNPLUG"]
+
+ aggregates: AGGREGATES.concat()
};
Please sign in to comment.
Something went wrong with that request. Please try again.