3 Copyright 2012 Yahoo! Inc. All rights reserved.
4 Licensed under the BSD License.
5 http://yuilibrary.com/license/
7 if (typeof _yuitest_coverage == "undefined"){
8 _yuitest_coverage = {};
9 _yuitest_coverline = function(src, line){
10 var coverage = _yuitest_coverage[src];
11 if (!coverage.lines[line]){
12 coverage.calledLines++;
14 coverage.lines[line]++;
16 _yuitest_coverfunc = function(src, name, line){
17 var coverage = _yuitest_coverage[src],
18 funcId = name + ":" + line;
19 if (!coverage.functions[funcId]){
20 coverage.calledFunctions++;
22 coverage.functions[funcId]++;
25 _yuitest_coverage["build/base-core/base-core.js"] = {
32 path: "build/base-core/base-core.js",
35 _yuitest_coverage["build/base-core/base-core.js"].code=["YUI.add('base-core', function (Y, NAME) {",""," /**"," * The base module provides the Base class, which objects requiring attribute and custom event support can extend. "," * The module also provides two ways to reuse code - It augments Base with the Plugin.Host interface which provides "," * plugin support and also provides the BaseCore.build method which provides a way to build custom classes using extensions."," *"," * @module base"," */",""," /**"," * <p>The base-core module provides the BaseCore class, the lightest version of Base, "," * which provides Base's basic lifecycle management and ATTRS construction support, "," * but doesn't fire init/destroy or attribute change events.</p> "," * "," * <p>It mixes in AttributeCore, which is the lightest version of Attribute</p>"," *"," * @module base"," * @submodule base-core"," */"," var O = Y.Object,"," L = Y.Lang,"," DOT = \".\","," INITIALIZED = \"initialized\","," DESTROYED = \"destroyed\","," INITIALIZER = \"initializer\","," VALUE = \"value\","," OBJECT_CONSTRUCTOR = Object.prototype.constructor,"," DEEP = \"deep\","," SHALLOW = \"shallow\","," DESTRUCTOR = \"destructor\",",""," AttributeCore = Y.AttributeCore,",""," _wlmix = function(r, s, wlhash) {"," var p;"," for (p in s) {"," if(wlhash[p]) { "," r[p] = s[p];"," }"," }"," return r;"," };",""," /**"," * The BaseCore class, is the lightest version of Base, and provides Base's "," * basic lifecycle management and ATTRS construction support, but doesn't "," * fire init/destroy or attribute change events."," *"," * BaseCore also handles the chaining of initializer and destructor methods across "," * the hierarchy as part of object construction and destruction. Additionally, attributes "," * configured through the static <a href=\"#property_BaseCore.ATTRS\">ATTRS</a> "," * property for each class in the hierarchy will be initialized by BaseCore."," *"," * Classes which require attribute support, but don't intend to use/expose attribute "," * change events can extend BaseCore instead of Base for optimal kweight and "," * runtime performance."," * "," * @class BaseCore"," * @constructor"," * @uses AttributeCore"," * @param {Object} cfg Object with configuration property name/value pairs. "," * The object can be used to provide initial values for the objects published "," * attributes."," */"," function BaseCore(cfg) {"," if (!this._BaseInvoked) {"," this._BaseInvoked = true;",""," this._initBase(cfg);"," }"," }",""," /**"," * The list of properties which can be configured for each attribute "," * (e.g. setter, getter, writeOnce, readOnly etc.)"," *"," * @property _ATTR_CFG"," * @type Array"," * @static"," * @private"," */"," BaseCore._ATTR_CFG = AttributeCore._ATTR_CFG.concat(\"cloneDefaultValue\");"," BaseCore._ATTR_CFG_HASH = Y.Array.hash(BaseCore._ATTR_CFG);",""," /**"," * The array of non-attribute configuration properties supported by this class. "," * "," * For example `BaseCore` defines a \"plugins\" configuration property which "," * should not be set up as an attribute. This property is primarily required so "," * that when <a href=\"#property__allowAdHocAttrs\">`_allowAdHocAttrs`</a> is enabled by a class, "," * non-attribute configuration properties don't get added as ad-hoc attributes. "," *"," * @property _NON_ATTRS_CFG"," * @type Array"," * @static"," * @private"," */"," BaseCore._NON_ATTRS_CFG = [\"plugins\"];",""," /**"," * This property controls whether or not instances of this class should"," * allow users to add ad-hoc attributes through the constructor configuration "," * hash."," *"," * AdHoc attributes are attributes which are not defined by the class, and are "," * not handled by the MyClass._NON_ATTRS_CFG "," * "," * @property _allowAdHocAttrs"," * @type boolean"," * @default undefined (false)"," * @protected"," */",""," /**"," * The string to be used to identify instances of this class."," * "," * Classes extending BaseCore, should define their own"," * static NAME property, which should be camelCase by"," * convention (e.g. MyClass.NAME = \"myClass\";)."," *"," * @property NAME"," * @type String"," * @static"," */"," BaseCore.NAME = \"baseCore\";",""," /**"," * The default set of attributes which will be available for instances of this class, and "," * their configuration. In addition to the configuration properties listed by "," * AttributeCore's <a href=\"AttributeCore.html#method_addAttr\">addAttr</a> method, "," * the attribute can also be configured with a \"cloneDefaultValue\" property, which "," * defines how the statically defined value field should be protected "," * (\"shallow\", \"deep\" and false are supported values). "," *"," * By default if the value is an object literal or an array it will be \"shallow\" "," * cloned, to protect the default value."," *"," * @property ATTRS"," * @type Object"," * @static"," */"," BaseCore.ATTRS = {"," /**"," * Flag indicating whether or not this object"," * has been through the init lifecycle phase."," *"," * @attribute initialized"," * @readonly"," * @default false"," * @type boolean"," */"," initialized: {"," readOnly:true,"," value:false"," },",""," /**"," * Flag indicating whether or not this object"," * has been through the destroy lifecycle phase."," *"," * @attribute destroyed"," * @readonly"," * @default false"," * @type boolean"," */"," destroyed: {"," readOnly:true,"," value:false"," }"," };",""," BaseCore.prototype = {",""," /**"," * Internal construction logic for BaseCore."," *"," * @method _initBase"," * @param {Object} config The constructor configuration object"," * @private"," */"," _initBase : function(config) {",""," Y.stamp(this);",""," this._initAttribute(config);",""," // If Plugin.Host has been augmented [ through base-pluginhost ], setup it's"," // initial state, but don't initialize Plugins yet. That's done after initialization."," var PluginHost = Y.Plugin && Y.Plugin.Host;"," if (this._initPlugins && PluginHost) {"," PluginHost.call(this);"," }",""," if (this._lazyAddAttrs !== false) { this._lazyAddAttrs = true; }",""," /**"," * The string used to identify the class of this object."," *"," * @deprecated Use this.constructor.NAME"," * @property name"," * @type String"," */"," this.name = this.constructor.NAME;"," "," this.init.apply(this, arguments);"," },",""," /**"," * Initializes AttributeCore "," * "," * @method _initAttribute"," * @private"," */"," _initAttribute: function() {"," AttributeCore.apply(this);"," },",""," /**"," * Init lifecycle method, invoked during construction. Sets up attributes "," * and invokes initializers for the class hierarchy."," *"," * @method init"," * @chainable"," * @param {Object} cfg Object with configuration property name/value pairs"," * @return {BaseCore} A reference to this object"," */"," init: function(cfg) {",""," this._baseInit(cfg);",""," return this;"," },",""," /**"," * Internal initialization implementation for BaseCore"," *"," * @method _baseInit"," * @private"," */"," _baseInit: function(cfg) {"," this._initHierarchy(cfg);",""," if (this._initPlugins) {"," // Need to initPlugins manually, to handle constructor parsing, static Plug parsing"," this._initPlugins(cfg);"," }"," this._set(INITIALIZED, true);"," },",""," /**"," * Destroy lifecycle method. Invokes destructors for the class hierarchy."," *"," * @method destroy"," * @return {BaseCore} A reference to this object"," * @chainable"," */"," destroy: function() {"," this._baseDestroy();"," return this;"," },",""," /**"," * Internal destroy implementation for BaseCore"," *"," * @method _baseDestroy"," * @private"," */"," _baseDestroy : function() {"," if (this._destroyPlugins) {"," this._destroyPlugins();"," }"," this._destroyHierarchy();"," this._set(DESTROYED, true);"," },",""," /**"," * Returns the class hierarchy for this object, with BaseCore being the last class in the array."," *"," * @method _getClasses"," * @protected"," * @return {Function[]} An array of classes (constructor functions), making up the class hierarchy for this object."," * This value is cached the first time the method, or _getAttrCfgs, is invoked. Subsequent invocations return the "," * cached value."," */"," _getClasses : function() {"," if (!this._classes) {"," this._initHierarchyData();"," }"," return this._classes;"," },",""," /**"," * Returns an aggregated set of attribute configurations, by traversing "," * the class hierarchy."," *"," * @method _getAttrCfgs"," * @protected"," * @return {Object} The hash of attribute configurations, aggregated across classes in the hierarchy"," * This value is cached the first time the method, or _getClasses, is invoked. Subsequent invocations return"," * the cached value."," */"," _getAttrCfgs : function() {"," if (!this._attrs) {"," this._initHierarchyData();"," }"," return this._attrs;"," },",""," /**"," * A helper method used when processing ATTRS across the class hierarchy during "," * initialization. Returns a disposable object with the attributes defined for "," * the provided class, extracted from the set of all attributes passed in."," *"," * @method _filterAttrCfs"," * @private"," *"," * @param {Function} clazz The class for which the desired attributes are required."," * @param {Object} allCfgs The set of all attribute configurations for this instance. "," * Attributes will be removed from this set, if they belong to the filtered class, so"," * that by the time all classes are processed, allCfgs will be empty."," * "," * @return {Object} The set of attributes belonging to the class passed in, in the form"," * of an object with attribute name/configuration pairs."," */"," _filterAttrCfgs : function(clazz, allCfgs) {"," var cfgs = null, attr, attrs = clazz.ATTRS;",""," if (attrs) {"," for (attr in attrs) {"," if (allCfgs[attr]) {"," cfgs = cfgs || {};"," cfgs[attr] = allCfgs[attr];"," allCfgs[attr] = null;"," }"," }"," }",""," return cfgs;"," },",""," /**"," * @method _filterAdHocAttrs"," * @private"," *"," * @param {Object} allAttrs The set of all attribute configurations for this instance. "," * Attributes will be removed from this set, if they belong to the filtered class, so"," * that by the time all classes are processed, allCfgs will be empty."," * @param {Object} userVals The config object passed in by the user, from which adhoc attrs are to be filtered."," * @return {Object} The set of adhoc attributes passed in, in the form"," * of an object with attribute name/configuration pairs."," */"," _filterAdHocAttrs : function(allAttrs, userVals) {"," var adHocs,"," nonAttrs = this._nonAttrs,"," attr;",""," if (userVals) {"," adHocs = {};"," for (attr in userVals) {"," if (!allAttrs[attr] && !nonAttrs[attr] && userVals.hasOwnProperty(attr)) {"," adHocs[attr] = {"," value:userVals[attr]"," };"," }"," }"," }",""," return adHocs;"," },",""," /**"," * A helper method used by _getClasses and _getAttrCfgs, which determines both"," * the array of classes and aggregate set of attribute configurations"," * across the class hierarchy for the instance."," *"," * @method _initHierarchyData"," * @private"," */"," _initHierarchyData : function() {"," var c = this.constructor,"," i,"," l,"," nonAttrsCfg,"," nonAttrs = (this._allowAdHocAttrs) ? {} : null,"," classes = [],"," attrs = [];",""," while (c) {"," // Add to classes"," classes[classes.length] = c;",""," // Add to attributes"," if (c.ATTRS) {"," attrs[attrs.length] = c.ATTRS;"," }",""," if (this._allowAdHocAttrs) {"," nonAttrsCfg = c._NON_ATTRS_CFG; "," if (nonAttrsCfg) {"," for (i = 0, l = nonAttrsCfg.length; i < l; i++) {"," nonAttrs[nonAttrsCfg[i]] = true;"," }"," }"," }",""," c = c.superclass ? c.superclass.constructor : null;"," }",""," this._classes = classes;"," this._nonAttrs = nonAttrs;"," this._attrs = this._aggregateAttrs(attrs);"," },",""," /**"," * Utility method to define the attribute hash used to filter/whitelist property mixes for "," * this class. "," * "," * @method _attrCfgHash"," * @private"," */"," _attrCfgHash: function() {"," return BaseCore._ATTR_CFG_HASH;"," },",""," /**"," * A helper method, used by _initHierarchyData to aggregate "," * attribute configuration across the instances class hierarchy."," *"," * The method will protect the attribute configuration value to protect the statically defined "," * default value in ATTRS if required (if the value is an object literal, array or the "," * attribute configuration has cloneDefaultValue set to shallow or deep)."," *"," * @method _aggregateAttrs"," * @private"," * @param {Array} allAttrs An array of ATTRS definitions across classes in the hierarchy "," * (subclass first, Base last)"," * @return {Object} The aggregate set of ATTRS definitions for the instance"," */"," _aggregateAttrs : function(allAttrs) {"," var attr,"," attrs,"," cfg,"," val,"," path,"," i,"," clone,"," cfgPropsHash = this._attrCfgHash(),"," aggAttr,"," aggAttrs = {};",""," if (allAttrs) {"," for (i = allAttrs.length-1; i >= 0; --i) {"," attrs = allAttrs[i];",""," for (attr in attrs) {"," if (attrs.hasOwnProperty(attr)) {",""," // Protect config passed in"," cfg = _wlmix({}, attrs[attr], cfgPropsHash);",""," val = cfg.value;"," clone = cfg.cloneDefaultValue;",""," if (val) {"," if ( (clone === undefined && (OBJECT_CONSTRUCTOR === val.constructor || L.isArray(val))) || clone === DEEP || clone === true) {"," cfg.value = Y.clone(val);"," } else if (clone === SHALLOW) {"," cfg.value = Y.merge(val);"," }"," // else if (clone === false), don't clone the static default value. "," // It's intended to be used by reference."," }",""," path = null;"," if (attr.indexOf(DOT) !== -1) {"," path = attr.split(DOT);"," attr = path.shift();"," }",""," aggAttr = aggAttrs[attr];"," if (path && aggAttr && aggAttr.value) {"," O.setValue(aggAttr.value, path, val);"," } else if (!path) {"," if (!aggAttr) {"," aggAttrs[attr] = cfg;"," } else {"," if (aggAttr.valueFn && VALUE in cfg) {"," aggAttr.valueFn = null; "," }"," _wlmix(aggAttr, cfg, cfgPropsHash);"," }"," }"," }"," }"," }"," }",""," return aggAttrs;"," },",""," /**"," * Initializes the class hierarchy for the instance, which includes "," * initializing attributes for each class defined in the class's "," * static <a href=\"#property_BaseCore.ATTRS\">ATTRS</a> property and "," * invoking the initializer method on the prototype of each class in the hierarchy."," *"," * @method _initHierarchy"," * @param {Object} userVals Object with configuration property name/value pairs"," * @private"," */"," _initHierarchy : function(userVals) {"," var lazy = this._lazyAddAttrs,"," constr,"," constrProto,"," ci,"," ei,"," el,"," extProto,"," exts,"," classes = this._getClasses(),"," attrCfgs = this._getAttrCfgs(),"," cl = classes.length - 1;",""," for (ci = cl; ci >= 0; ci--) {",""," constr = classes[ci];"," constrProto = constr.prototype;"," exts = constr._yuibuild && constr._yuibuild.exts; ",""," if (exts) {"," for (ei = 0, el = exts.length; ei < el; ei++) {"," exts[ei].apply(this, arguments);"," }"," }",""," this.addAttrs(this._filterAttrCfgs(constr, attrCfgs), userVals, lazy);",""," if (this._allowAdHocAttrs && ci === cl) { "," this.addAttrs(this._filterAdHocAttrs(attrCfgs, userVals), userVals, lazy);"," }",""," // Using INITIALIZER in hasOwnProperty check, for performance reasons (helps IE6 avoid GC thresholds when"," // referencing string literals). Not using it in apply, again, for performance \".\" is faster. "," if (constrProto.hasOwnProperty(INITIALIZER)) {"," constrProto.initializer.apply(this, arguments);"," }",""," if (exts) {"," for (ei = 0; ei < el; ei++) {"," extProto = exts[ei].prototype;"," if (extProto.hasOwnProperty(INITIALIZER)) {"," extProto.initializer.apply(this, arguments);"," }"," }"," }"," }"," },",""," /**"," * Destroys the class hierarchy for this instance by invoking"," * the destructor method on the prototype of each class in the hierarchy."," *"," * @method _destroyHierarchy"," * @private"," */"," _destroyHierarchy : function() {"," var constr,"," constrProto,"," ci, cl, ei, el, exts, extProto,"," classes = this._getClasses();",""," for (ci = 0, cl = classes.length; ci < cl; ci++) {"," constr = classes[ci];"," constrProto = constr.prototype;"," exts = constr._yuibuild && constr._yuibuild.exts; ",""," if (exts) {"," for (ei = 0, el = exts.length; ei < el; ei++) {"," extProto = exts[ei].prototype;"," if (extProto.hasOwnProperty(DESTRUCTOR)) {"," extProto.destructor.apply(this, arguments);"," }"," }"," }",""," if (constrProto.hasOwnProperty(DESTRUCTOR)) {"," constrProto.destructor.apply(this, arguments);"," }"," }"," },",""," /**"," * Default toString implementation. Provides the constructor NAME"," * and the instance guid, if set."," *"," * @method toString"," * @return {String} String representation for this object"," */"," toString: function() {"," return this.name + \"[\" + Y.stamp(this, true) + \"]\";"," }"," };",""," // Straightup augment, no wrapper functions"," Y.mix(BaseCore, AttributeCore, false, null, 1);",""," // Fix constructor"," BaseCore.prototype.constructor = BaseCore;",""," Y.BaseCore = BaseCore;","","","}, '3.7.1', {\"requires\": [\"attribute-core\"]});"];
36 _yuitest_coverage["build/base-core/base-core.js"].lines = {"1":0,"21":0,"36":0,"37":0,"38":0,"39":0,"42":0,"66":0,"67":0,"68":0,"70":0,"83":0,"84":0,"99":0,"126":0,"143":0,"173":0,"184":0,"186":0,"190":0,"191":0,"192":0,"195":0,"204":0,"206":0,"216":0,"230":0,"232":0,"242":0,"244":0,"246":0,"248":0,"259":0,"260":0,"270":0,"271":0,"273":0,"274":0,"287":0,"288":0,"290":0,"304":0,"305":0,"307":0,"327":0,"329":0,"330":0,"331":0,"332":0,"333":0,"334":0,"339":0,"354":0,"358":0,"359":0,"360":0,"361":0,"362":0,"369":0,"381":0,"389":0,"391":0,"394":0,"395":0,"398":0,"399":0,"400":0,"401":0,"402":0,"407":0,"410":0,"411":0,"412":0,"423":0,"441":0,"452":0,"453":0,"454":0,"456":0,"457":0,"460":0,"462":0,"463":0,"465":0,"466":0,"467":0,"468":0,"469":0,"475":0,"476":0,"477":0,"478":0,"481":0,"482":0,"483":0,"484":0,"485":0,"486":0,"488":0,"489":0,"491":0,"499":0,"513":0,"525":0,"527":0,"528":0,"529":0,"531":0,"532":0,"533":0,"537":0,"539":0,"540":0,"545":0,"546":0,"549":0,"550":0,"551":0,"552":0,"553":0,"568":0,"573":0,"574":0,"575":0,"576":0,"578":0,"579":0,"580":0,"581":0,"582":0,"587":0,"588":0,"601":0,"606":0,"609":0,"611":0};
37 _yuitest_coverage["build/base-core/base-core.js"].functions = {"_wlmix:35":0,"BaseCore:66":0,"_initBase:182":0,"_initAttribute:215":0,"init:228":0,"_baseInit:241":0,"destroy:258":0,"_baseDestroy:269":0,"_getClasses:286":0,"_getAttrCfgs:303":0,"_filterAttrCfgs:326":0,"_filterAdHocAttrs:353":0,"_initHierarchyData:380":0,"_attrCfgHash:422":0,"_aggregateAttrs:440":0,"_initHierarchy:512":0,"_destroyHierarchy:567":0,"toString:600":0,"(anonymous 1):1":0};
38 _yuitest_coverage["build/base-core/base-core.js"].coveredLines = 136;
39 _yuitest_coverage["build/base-core/base-core.js"].coveredFunctions = 19;
40 _yuitest_coverline("build/base-core/base-core.js", 1);
41 YUI.add('base-core', function (Y, NAME) {
44 * The base module provides the Base class, which objects requiring attribute and custom event support can extend.
45 * The module also provides two ways to reuse code - It augments Base with the Plugin.Host interface which provides
46 * plugin support and also provides the BaseCore.build method which provides a way to build custom classes using extensions.
52 * <p>The base-core module provides the BaseCore class, the lightest version of Base,
53 * which provides Base's basic lifecycle management and ATTRS construction support,
54 * but doesn't fire init/destroy or attribute change events.</p>
56 * <p>It mixes in AttributeCore, which is the lightest version of Attribute</p>
59 * @submodule base-core
61 _yuitest_coverfunc("build/base-core/base-core.js", "(anonymous 1)", 1);
62 _yuitest_coverline("build/base-core/base-core.js", 21);
66 INITIALIZED = "initialized",
67 DESTROYED = "destroyed",
68 INITIALIZER = "initializer",
70 OBJECT_CONSTRUCTOR = Object.prototype.constructor,
73 DESTRUCTOR = "destructor",
75 AttributeCore = Y.AttributeCore,
77 _wlmix = function(r, s, wlhash) {
78 _yuitest_coverfunc("build/base-core/base-core.js", "_wlmix", 35);
79 _yuitest_coverline("build/base-core/base-core.js", 36);
81 _yuitest_coverline("build/base-core/base-core.js", 37);
83 _yuitest_coverline("build/base-core/base-core.js", 38);
85 _yuitest_coverline("build/base-core/base-core.js", 39);
89 _yuitest_coverline("build/base-core/base-core.js", 42);
94 * The BaseCore class, is the lightest version of Base, and provides Base's
95 * basic lifecycle management and ATTRS construction support, but doesn't
96 * fire init/destroy or attribute change events.
98 * BaseCore also handles the chaining of initializer and destructor methods across
99 * the hierarchy as part of object construction and destruction. Additionally, attributes
100 * configured through the static <a href="#property_BaseCore.ATTRS">ATTRS</a>
101 * property for each class in the hierarchy will be initialized by BaseCore.
103 * Classes which require attribute support, but don't intend to use/expose attribute
104 * change events can extend BaseCore instead of Base for optimal kweight and
105 * runtime performance.
109 * @uses AttributeCore
110 * @param {Object} cfg Object with configuration property name/value pairs.
111 * The object can be used to provide initial values for the objects published
114 _yuitest_coverline("build/base-core/base-core.js", 66);
115 function BaseCore(cfg) {
116 _yuitest_coverfunc("build/base-core/base-core.js", "BaseCore", 66);
117 _yuitest_coverline("build/base-core/base-core.js", 67);
118 if (!this._BaseInvoked) {
119 _yuitest_coverline("build/base-core/base-core.js", 68);
120 this._BaseInvoked = true;
122 _yuitest_coverline("build/base-core/base-core.js", 70);
128 * The list of properties which can be configured for each attribute
129 * (e.g. setter, getter, writeOnce, readOnly etc.)
131 * @property _ATTR_CFG
136 _yuitest_coverline("build/base-core/base-core.js", 83);
137 BaseCore._ATTR_CFG = AttributeCore._ATTR_CFG.concat("cloneDefaultValue");
138 _yuitest_coverline("build/base-core/base-core.js", 84);
139 BaseCore._ATTR_CFG_HASH = Y.Array.hash(BaseCore._ATTR_CFG);
142 * The array of non-attribute configuration properties supported by this class.
144 * For example `BaseCore` defines a "plugins" configuration property which
145 * should not be set up as an attribute. This property is primarily required so
146 * that when <a href="#property__allowAdHocAttrs">`_allowAdHocAttrs`</a> is enabled by a class,
147 * non-attribute configuration properties don't get added as ad-hoc attributes.
149 * @property _NON_ATTRS_CFG
154 _yuitest_coverline("build/base-core/base-core.js", 99);
155 BaseCore._NON_ATTRS_CFG = ["plugins"];
158 * This property controls whether or not instances of this class should
159 * allow users to add ad-hoc attributes through the constructor configuration
162 * AdHoc attributes are attributes which are not defined by the class, and are
163 * not handled by the MyClass._NON_ATTRS_CFG
165 * @property _allowAdHocAttrs
167 * @default undefined (false)
172 * The string to be used to identify instances of this class.
174 * Classes extending BaseCore, should define their own
175 * static NAME property, which should be camelCase by
176 * convention (e.g. MyClass.NAME = "myClass";).
182 _yuitest_coverline("build/base-core/base-core.js", 126);
183 BaseCore.NAME = "baseCore";
186 * The default set of attributes which will be available for instances of this class, and
187 * their configuration. In addition to the configuration properties listed by
188 * AttributeCore's <a href="AttributeCore.html#method_addAttr">addAttr</a> method,
189 * the attribute can also be configured with a "cloneDefaultValue" property, which
190 * defines how the statically defined value field should be protected
191 * ("shallow", "deep" and false are supported values).
193 * By default if the value is an object literal or an array it will be "shallow"
194 * cloned, to protect the default value.
200 _yuitest_coverline("build/base-core/base-core.js", 143);
203 * Flag indicating whether or not this object
204 * has been through the init lifecycle phase.
206 * @attribute initialized
217 * Flag indicating whether or not this object
218 * has been through the destroy lifecycle phase.
220 * @attribute destroyed
231 _yuitest_coverline("build/base-core/base-core.js", 173);
232 BaseCore.prototype = {
235 * Internal construction logic for BaseCore.
238 * @param {Object} config The constructor configuration object
241 _initBase : function(config) {
243 _yuitest_coverfunc("build/base-core/base-core.js", "_initBase", 182);
244 _yuitest_coverline("build/base-core/base-core.js", 184);
247 _yuitest_coverline("build/base-core/base-core.js", 186);
248 this._initAttribute(config);
250 // If Plugin.Host has been augmented [ through base-pluginhost ], setup it's
251 // initial state, but don't initialize Plugins yet. That's done after initialization.
252 _yuitest_coverline("build/base-core/base-core.js", 190);
253 var PluginHost = Y.Plugin && Y.Plugin.Host;
254 _yuitest_coverline("build/base-core/base-core.js", 191);
255 if (this._initPlugins && PluginHost) {
256 _yuitest_coverline("build/base-core/base-core.js", 192);
257 PluginHost.call(this);
260 _yuitest_coverline("build/base-core/base-core.js", 195);
261 if (this._lazyAddAttrs !== false) { this._lazyAddAttrs = true; }
264 * The string used to identify the class of this object.
266 * @deprecated Use this.constructor.NAME
270 _yuitest_coverline("build/base-core/base-core.js", 204);
271 this.name = this.constructor.NAME;
273 _yuitest_coverline("build/base-core/base-core.js", 206);
274 this.init.apply(this, arguments);
278 * Initializes AttributeCore
280 * @method _initAttribute
283 _initAttribute: function() {
284 _yuitest_coverfunc("build/base-core/base-core.js", "_initAttribute", 215);
285 _yuitest_coverline("build/base-core/base-core.js", 216);
286 AttributeCore.apply(this);
290 * Init lifecycle method, invoked during construction. Sets up attributes
291 * and invokes initializers for the class hierarchy.
295 * @param {Object} cfg Object with configuration property name/value pairs
296 * @return {BaseCore} A reference to this object
298 init: function(cfg) {
300 _yuitest_coverfunc("build/base-core/base-core.js", "init", 228);
301 _yuitest_coverline("build/base-core/base-core.js", 230);
304 _yuitest_coverline("build/base-core/base-core.js", 232);
309 * Internal initialization implementation for BaseCore
314 _baseInit: function(cfg) {
315 _yuitest_coverfunc("build/base-core/base-core.js", "_baseInit", 241);
316 _yuitest_coverline("build/base-core/base-core.js", 242);
317 this._initHierarchy(cfg);
319 _yuitest_coverline("build/base-core/base-core.js", 244);
320 if (this._initPlugins) {
321 // Need to initPlugins manually, to handle constructor parsing, static Plug parsing
322 _yuitest_coverline("build/base-core/base-core.js", 246);
323 this._initPlugins(cfg);
325 _yuitest_coverline("build/base-core/base-core.js", 248);
326 this._set(INITIALIZED, true);
330 * Destroy lifecycle method. Invokes destructors for the class hierarchy.
333 * @return {BaseCore} A reference to this object
336 destroy: function() {
337 _yuitest_coverfunc("build/base-core/base-core.js", "destroy", 258);
338 _yuitest_coverline("build/base-core/base-core.js", 259);
340 _yuitest_coverline("build/base-core/base-core.js", 260);
345 * Internal destroy implementation for BaseCore
347 * @method _baseDestroy
350 _baseDestroy : function() {
351 _yuitest_coverfunc("build/base-core/base-core.js", "_baseDestroy", 269);
352 _yuitest_coverline("build/base-core/base-core.js", 270);
353 if (this._destroyPlugins) {
354 _yuitest_coverline("build/base-core/base-core.js", 271);
355 this._destroyPlugins();
357 _yuitest_coverline("build/base-core/base-core.js", 273);
358 this._destroyHierarchy();
359 _yuitest_coverline("build/base-core/base-core.js", 274);
360 this._set(DESTROYED, true);
364 * Returns the class hierarchy for this object, with BaseCore being the last class in the array.
366 * @method _getClasses
368 * @return {Function[]} An array of classes (constructor functions), making up the class hierarchy for this object.
369 * This value is cached the first time the method, or _getAttrCfgs, is invoked. Subsequent invocations return the
372 _getClasses : function() {
373 _yuitest_coverfunc("build/base-core/base-core.js", "_getClasses", 286);
374 _yuitest_coverline("build/base-core/base-core.js", 287);
375 if (!this._classes) {
376 _yuitest_coverline("build/base-core/base-core.js", 288);
377 this._initHierarchyData();
379 _yuitest_coverline("build/base-core/base-core.js", 290);
380 return this._classes;
384 * Returns an aggregated set of attribute configurations, by traversing
385 * the class hierarchy.
387 * @method _getAttrCfgs
389 * @return {Object} The hash of attribute configurations, aggregated across classes in the hierarchy
390 * This value is cached the first time the method, or _getClasses, is invoked. Subsequent invocations return
393 _getAttrCfgs : function() {
394 _yuitest_coverfunc("build/base-core/base-core.js", "_getAttrCfgs", 303);
395 _yuitest_coverline("build/base-core/base-core.js", 304);
397 _yuitest_coverline("build/base-core/base-core.js", 305);
398 this._initHierarchyData();
400 _yuitest_coverline("build/base-core/base-core.js", 307);
405 * A helper method used when processing ATTRS across the class hierarchy during
406 * initialization. Returns a disposable object with the attributes defined for
407 * the provided class, extracted from the set of all attributes passed in.
409 * @method _filterAttrCfs
412 * @param {Function} clazz The class for which the desired attributes are required.
413 * @param {Object} allCfgs The set of all attribute configurations for this instance.
414 * Attributes will be removed from this set, if they belong to the filtered class, so
415 * that by the time all classes are processed, allCfgs will be empty.
417 * @return {Object} The set of attributes belonging to the class passed in, in the form
418 * of an object with attribute name/configuration pairs.
420 _filterAttrCfgs : function(clazz, allCfgs) {
421 _yuitest_coverfunc("build/base-core/base-core.js", "_filterAttrCfgs", 326);
422 _yuitest_coverline("build/base-core/base-core.js", 327);
423 var cfgs = null, attr, attrs = clazz.ATTRS;
425 _yuitest_coverline("build/base-core/base-core.js", 329);
427 _yuitest_coverline("build/base-core/base-core.js", 330);
428 for (attr in attrs) {
429 _yuitest_coverline("build/base-core/base-core.js", 331);
431 _yuitest_coverline("build/base-core/base-core.js", 332);
433 _yuitest_coverline("build/base-core/base-core.js", 333);
434 cfgs[attr] = allCfgs[attr];
435 _yuitest_coverline("build/base-core/base-core.js", 334);
436 allCfgs[attr] = null;
441 _yuitest_coverline("build/base-core/base-core.js", 339);
446 * @method _filterAdHocAttrs
449 * @param {Object} allAttrs The set of all attribute configurations for this instance.
450 * Attributes will be removed from this set, if they belong to the filtered class, so
451 * that by the time all classes are processed, allCfgs will be empty.
452 * @param {Object} userVals The config object passed in by the user, from which adhoc attrs are to be filtered.
453 * @return {Object} The set of adhoc attributes passed in, in the form
454 * of an object with attribute name/configuration pairs.
456 _filterAdHocAttrs : function(allAttrs, userVals) {
457 _yuitest_coverfunc("build/base-core/base-core.js", "_filterAdHocAttrs", 353);
458 _yuitest_coverline("build/base-core/base-core.js", 354);
460 nonAttrs = this._nonAttrs,
463 _yuitest_coverline("build/base-core/base-core.js", 358);
465 _yuitest_coverline("build/base-core/base-core.js", 359);
467 _yuitest_coverline("build/base-core/base-core.js", 360);
468 for (attr in userVals) {
469 _yuitest_coverline("build/base-core/base-core.js", 361);
470 if (!allAttrs[attr] && !nonAttrs[attr] && userVals.hasOwnProperty(attr)) {
471 _yuitest_coverline("build/base-core/base-core.js", 362);
479 _yuitest_coverline("build/base-core/base-core.js", 369);
484 * A helper method used by _getClasses and _getAttrCfgs, which determines both
485 * the array of classes and aggregate set of attribute configurations
486 * across the class hierarchy for the instance.
488 * @method _initHierarchyData
491 _initHierarchyData : function() {
492 _yuitest_coverfunc("build/base-core/base-core.js", "_initHierarchyData", 380);
493 _yuitest_coverline("build/base-core/base-core.js", 381);
494 var c = this.constructor,
498 nonAttrs = (this._allowAdHocAttrs) ? {} : null,
502 _yuitest_coverline("build/base-core/base-core.js", 389);
505 _yuitest_coverline("build/base-core/base-core.js", 391);
506 classes[classes.length] = c;
509 _yuitest_coverline("build/base-core/base-core.js", 394);
511 _yuitest_coverline("build/base-core/base-core.js", 395);
512 attrs[attrs.length] = c.ATTRS;
515 _yuitest_coverline("build/base-core/base-core.js", 398);
516 if (this._allowAdHocAttrs) {
517 _yuitest_coverline("build/base-core/base-core.js", 399);
518 nonAttrsCfg = c._NON_ATTRS_CFG;
519 _yuitest_coverline("build/base-core/base-core.js", 400);
521 _yuitest_coverline("build/base-core/base-core.js", 401);
522 for (i = 0, l = nonAttrsCfg.length; i < l; i++) {
523 _yuitest_coverline("build/base-core/base-core.js", 402);
524 nonAttrs[nonAttrsCfg[i]] = true;
529 _yuitest_coverline("build/base-core/base-core.js", 407);
530 c = c.superclass ? c.superclass.constructor : null;
533 _yuitest_coverline("build/base-core/base-core.js", 410);
534 this._classes = classes;
535 _yuitest_coverline("build/base-core/base-core.js", 411);
536 this._nonAttrs = nonAttrs;
537 _yuitest_coverline("build/base-core/base-core.js", 412);
538 this._attrs = this._aggregateAttrs(attrs);
542 * Utility method to define the attribute hash used to filter/whitelist property mixes for
545 * @method _attrCfgHash
548 _attrCfgHash: function() {
549 _yuitest_coverfunc("build/base-core/base-core.js", "_attrCfgHash", 422);
550 _yuitest_coverline("build/base-core/base-core.js", 423);
551 return BaseCore._ATTR_CFG_HASH;
555 * A helper method, used by _initHierarchyData to aggregate
556 * attribute configuration across the instances class hierarchy.
558 * The method will protect the attribute configuration value to protect the statically defined
559 * default value in ATTRS if required (if the value is an object literal, array or the
560 * attribute configuration has cloneDefaultValue set to shallow or deep).
562 * @method _aggregateAttrs
564 * @param {Array} allAttrs An array of ATTRS definitions across classes in the hierarchy
565 * (subclass first, Base last)
566 * @return {Object} The aggregate set of ATTRS definitions for the instance
568 _aggregateAttrs : function(allAttrs) {
569 _yuitest_coverfunc("build/base-core/base-core.js", "_aggregateAttrs", 440);
570 _yuitest_coverline("build/base-core/base-core.js", 441);
578 cfgPropsHash = this._attrCfgHash(),
582 _yuitest_coverline("build/base-core/base-core.js", 452);
584 _yuitest_coverline("build/base-core/base-core.js", 453);
585 for (i = allAttrs.length-1; i >= 0; --i) {
586 _yuitest_coverline("build/base-core/base-core.js", 454);
589 _yuitest_coverline("build/base-core/base-core.js", 456);
590 for (attr in attrs) {
591 _yuitest_coverline("build/base-core/base-core.js", 457);
592 if (attrs.hasOwnProperty(attr)) {
594 // Protect config passed in
595 _yuitest_coverline("build/base-core/base-core.js", 460);
596 cfg = _wlmix({}, attrs[attr], cfgPropsHash);
598 _yuitest_coverline("build/base-core/base-core.js", 462);
600 _yuitest_coverline("build/base-core/base-core.js", 463);
601 clone = cfg.cloneDefaultValue;
603 _yuitest_coverline("build/base-core/base-core.js", 465);
605 _yuitest_coverline("build/base-core/base-core.js", 466);
606 if ( (clone === undefined && (OBJECT_CONSTRUCTOR === val.constructor || L.isArray(val))) || clone === DEEP || clone === true) {
607 _yuitest_coverline("build/base-core/base-core.js", 467);
608 cfg.value = Y.clone(val);
609 } else {_yuitest_coverline("build/base-core/base-core.js", 468);
610 if (clone === SHALLOW) {
611 _yuitest_coverline("build/base-core/base-core.js", 469);
612 cfg.value = Y.merge(val);
614 // else if (clone === false), don't clone the static default value.
615 // It's intended to be used by reference.
618 _yuitest_coverline("build/base-core/base-core.js", 475);
620 _yuitest_coverline("build/base-core/base-core.js", 476);
621 if (attr.indexOf(DOT) !== -1) {
622 _yuitest_coverline("build/base-core/base-core.js", 477);
623 path = attr.split(DOT);
624 _yuitest_coverline("build/base-core/base-core.js", 478);
628 _yuitest_coverline("build/base-core/base-core.js", 481);
629 aggAttr = aggAttrs[attr];
630 _yuitest_coverline("build/base-core/base-core.js", 482);
631 if (path && aggAttr && aggAttr.value) {
632 _yuitest_coverline("build/base-core/base-core.js", 483);
633 O.setValue(aggAttr.value, path, val);
634 } else {_yuitest_coverline("build/base-core/base-core.js", 484);
636 _yuitest_coverline("build/base-core/base-core.js", 485);
638 _yuitest_coverline("build/base-core/base-core.js", 486);
639 aggAttrs[attr] = cfg;
641 _yuitest_coverline("build/base-core/base-core.js", 488);
642 if (aggAttr.valueFn && VALUE in cfg) {
643 _yuitest_coverline("build/base-core/base-core.js", 489);
644 aggAttr.valueFn = null;
646 _yuitest_coverline("build/base-core/base-core.js", 491);
647 _wlmix(aggAttr, cfg, cfgPropsHash);
655 _yuitest_coverline("build/base-core/base-core.js", 499);
660 * Initializes the class hierarchy for the instance, which includes
661 * initializing attributes for each class defined in the class's
662 * static <a href="#property_BaseCore.ATTRS">ATTRS</a> property and
663 * invoking the initializer method on the prototype of each class in the hierarchy.
665 * @method _initHierarchy
666 * @param {Object} userVals Object with configuration property name/value pairs
669 _initHierarchy : function(userVals) {
670 _yuitest_coverfunc("build/base-core/base-core.js", "_initHierarchy", 512);
671 _yuitest_coverline("build/base-core/base-core.js", 513);
672 var lazy = this._lazyAddAttrs,
680 classes = this._getClasses(),
681 attrCfgs = this._getAttrCfgs(),
682 cl = classes.length - 1;
684 _yuitest_coverline("build/base-core/base-core.js", 525);
685 for (ci = cl; ci >= 0; ci--) {
687 _yuitest_coverline("build/base-core/base-core.js", 527);
688 constr = classes[ci];
689 _yuitest_coverline("build/base-core/base-core.js", 528);
690 constrProto = constr.prototype;
691 _yuitest_coverline("build/base-core/base-core.js", 529);
692 exts = constr._yuibuild && constr._yuibuild.exts;
694 _yuitest_coverline("build/base-core/base-core.js", 531);
696 _yuitest_coverline("build/base-core/base-core.js", 532);
697 for (ei = 0, el = exts.length; ei < el; ei++) {
698 _yuitest_coverline("build/base-core/base-core.js", 533);
699 exts[ei].apply(this, arguments);
703 _yuitest_coverline("build/base-core/base-core.js", 537);
704 this.addAttrs(this._filterAttrCfgs(constr, attrCfgs), userVals, lazy);
706 _yuitest_coverline("build/base-core/base-core.js", 539);
707 if (this._allowAdHocAttrs && ci === cl) {
708 _yuitest_coverline("build/base-core/base-core.js", 540);
709 this.addAttrs(this._filterAdHocAttrs(attrCfgs, userVals), userVals, lazy);
712 // Using INITIALIZER in hasOwnProperty check, for performance reasons (helps IE6 avoid GC thresholds when
713 // referencing string literals). Not using it in apply, again, for performance "." is faster.
714 _yuitest_coverline("build/base-core/base-core.js", 545);
715 if (constrProto.hasOwnProperty(INITIALIZER)) {
716 _yuitest_coverline("build/base-core/base-core.js", 546);
717 constrProto.initializer.apply(this, arguments);
720 _yuitest_coverline("build/base-core/base-core.js", 549);
722 _yuitest_coverline("build/base-core/base-core.js", 550);
723 for (ei = 0; ei < el; ei++) {
724 _yuitest_coverline("build/base-core/base-core.js", 551);
725 extProto = exts[ei].prototype;
726 _yuitest_coverline("build/base-core/base-core.js", 552);
727 if (extProto.hasOwnProperty(INITIALIZER)) {
728 _yuitest_coverline("build/base-core/base-core.js", 553);
729 extProto.initializer.apply(this, arguments);
737 * Destroys the class hierarchy for this instance by invoking
738 * the destructor method on the prototype of each class in the hierarchy.
740 * @method _destroyHierarchy
743 _destroyHierarchy : function() {
744 _yuitest_coverfunc("build/base-core/base-core.js", "_destroyHierarchy", 567);
745 _yuitest_coverline("build/base-core/base-core.js", 568);
748 ci, cl, ei, el, exts, extProto,
749 classes = this._getClasses();
751 _yuitest_coverline("build/base-core/base-core.js", 573);
752 for (ci = 0, cl = classes.length; ci < cl; ci++) {
753 _yuitest_coverline("build/base-core/base-core.js", 574);
754 constr = classes[ci];
755 _yuitest_coverline("build/base-core/base-core.js", 575);
756 constrProto = constr.prototype;
757 _yuitest_coverline("build/base-core/base-core.js", 576);
758 exts = constr._yuibuild && constr._yuibuild.exts;
760 _yuitest_coverline("build/base-core/base-core.js", 578);
762 _yuitest_coverline("build/base-core/base-core.js", 579);
763 for (ei = 0, el = exts.length; ei < el; ei++) {
764 _yuitest_coverline("build/base-core/base-core.js", 580);
765 extProto = exts[ei].prototype;
766 _yuitest_coverline("build/base-core/base-core.js", 581);
767 if (extProto.hasOwnProperty(DESTRUCTOR)) {
768 _yuitest_coverline("build/base-core/base-core.js", 582);
769 extProto.destructor.apply(this, arguments);
774 _yuitest_coverline("build/base-core/base-core.js", 587);
775 if (constrProto.hasOwnProperty(DESTRUCTOR)) {
776 _yuitest_coverline("build/base-core/base-core.js", 588);
777 constrProto.destructor.apply(this, arguments);
783 * Default toString implementation. Provides the constructor NAME
784 * and the instance guid, if set.
787 * @return {String} String representation for this object
789 toString: function() {
790 _yuitest_coverfunc("build/base-core/base-core.js", "toString", 600);
791 _yuitest_coverline("build/base-core/base-core.js", 601);
792 return this.name + "[" + Y.stamp(this, true) + "]";
796 // Straightup augment, no wrapper functions
797 _yuitest_coverline("build/base-core/base-core.js", 606);
798 Y.mix(BaseCore, AttributeCore, false, null, 1);
801 _yuitest_coverline("build/base-core/base-core.js", 609);
802 BaseCore.prototype.constructor = BaseCore;
804 _yuitest_coverline("build/base-core/base-core.js", 611);
805 Y.BaseCore = BaseCore;
808 }, '3.7.1', {"requires": ["attribute-core"]});