diff --git a/.travis.yml b/.travis.yml index 67c46676356..d9b26cd502a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,3 +15,5 @@ install: - ./src/common/travis/install.sh script: - ./src/common/travis/test.sh +git: + depth: 30 diff --git a/build/attribute-core/attribute-core-coverage.js b/build/attribute-core/attribute-core-coverage.js index 408e3fa7124..a2fec0b352a 100644 --- a/build/attribute-core/attribute-core-coverage.js +++ b/build/attribute-core/attribute-core-coverage.js @@ -26,10 +26,10 @@ _yuitest_coverage["build/attribute-core/attribute-core.js"] = { path: "build/attribute-core/attribute-core.js", code: [] }; -_yuitest_coverage["build/attribute-core/attribute-core.js"].code=["YUI.add('attribute-core', function (Y, NAME) {",""," /**"," * The State class maintains state for a collection of named items, with"," * a varying number of properties defined."," *"," * It avoids the need to create a separate class for the item, and separate instances"," * of these classes for each item, by storing the state in a 2 level hash table,"," * improving performance when the number of items is likely to be large."," *"," * @constructor"," * @class State"," */"," Y.State = function() {"," /**"," * Hash of attributes"," * @property data"," */"," this.data = {};"," };",""," Y.State.prototype = {",""," /**"," * Adds a property to an item."," *"," * @method add"," * @param name {String} The name of the item."," * @param key {String} The name of the property."," * @param val {Any} The value of the property."," */"," add: function(name, key, val) {"," var item = this.data[name];",""," if (!item) {"," item = this.data[name] = {};"," }",""," item[key] = val;"," },",""," /**"," * Adds multiple properties to an item."," *"," * @method addAll"," * @param name {String} The name of the item."," * @param obj {Object} A hash of property/value pairs."," */"," addAll: function(name, obj) {"," var item = this.data[name],"," key;",""," if (!item) {"," item = this.data[name] = {};"," }",""," for (key in obj) {"," if (obj.hasOwnProperty(key)) {"," item[key] = obj[key];"," }"," }"," },",""," /**"," * Removes a property from an item."," *"," * @method remove"," * @param name {String} The name of the item."," * @param key {String} The property to remove."," */"," remove: function(name, key) {"," var item = this.data[name];",""," if (item) {"," delete item[key];"," }"," },",""," /**"," * Removes multiple properties from an item, or removes the item completely."," *"," * @method removeAll"," * @param name {String} The name of the item."," * @param obj {Object|Array} Collection of properties to delete. If not provided, the entire item is removed."," */"," removeAll: function(name, obj) {"," var data;",""," if (!obj) {"," data = this.data;",""," if (name in data) {"," delete data[name];"," }"," } else {"," Y.each(obj, function(value, key) {"," this.remove(name, typeof key === 'string' ? key : value);"," }, this);"," }"," },",""," /**"," * For a given item, returns the value of the property requested, or undefined if not found."," *"," * @method get"," * @param name {String} The name of the item"," * @param key {String} Optional. The property value to retrieve."," * @return {Any} The value of the supplied property."," */"," get: function(name, key) {"," var item = this.data[name];",""," if (item) {"," return item[key];"," }"," },",""," /**"," * For the given item, returns an object with all of the"," * item's property/value pairs. By default the object returned"," * is a shallow copy of the stored data, but passing in true"," * as the second parameter will return a reference to the stored"," * data."," *"," * @method getAll"," * @param name {String} The name of the item"," * @param reference {boolean} true, if you want a reference to the stored"," * object"," * @return {Object} An object with property/value pairs for the item."," */"," getAll : function(name, reference) {"," var item = this.data[name],"," key, obj;",""," if (reference) {"," obj = item;"," } else if (item) {"," obj = {};",""," for (key in item) {"," if (item.hasOwnProperty(key)) {"," obj[key] = item[key];"," }"," }"," }",""," return obj;"," }"," };"," /**"," * The attribute module provides an augmentable Attribute implementation, which"," * adds configurable attributes and attribute change events to the class being"," * augmented. It also provides a State class, which is used internally by Attribute,"," * but can also be used independently to provide a name/property/value data structure to"," * store state."," *"," * @module attribute"," */",""," /**"," * The attribute-core submodule provides the lightest level of attribute handling support"," * without Attribute change events, or lesser used methods such as reset(), modifyAttrs(),"," * and removeAttr()."," *"," * @module attribute"," * @submodule attribute-core"," */"," var O = Y.Object,"," Lang = Y.Lang,",""," DOT = \".\",",""," // Externally configurable props"," GETTER = \"getter\","," SETTER = \"setter\","," READ_ONLY = \"readOnly\","," WRITE_ONCE = \"writeOnce\","," INIT_ONLY = \"initOnly\","," VALIDATOR = \"validator\","," VALUE = \"value\","," VALUE_FN = \"valueFn\","," LAZY_ADD = \"lazyAdd\",",""," // Used for internal state management"," ADDED = \"added\","," BYPASS_PROXY = \"_bypassProxy\","," INITIALIZING = \"initializing\","," INIT_VALUE = \"initValue\","," LAZY = \"lazy\","," IS_LAZY_ADD = \"isLazyAdd\",",""," INVALID_VALUE;",""," /**"," *
"," * AttributeCore provides the lightest level of configurable attribute support. It is designed to be"," * augmented on to a host class, and provides the host with the ability to configure"," * attributes to store and retrieve state, but without support for attribute change events."," *
"," *For example, attributes added to the host can be configured:
"," *See the addAttr method, for the complete set of configuration"," * options available for attributes.
"," *"," *Object/Classes based on AttributeCore can augment AttributeObservable"," * (with true for overwrite) and AttributeExtras to add attribute event and"," * additional, less commonly used attribute methods, such as `modifyAttr`, `removeAttr` and `reset`.
"," *"," * @class AttributeCore"," * @param attrs {Object} The attributes to add during construction (passed through to addAttrs)."," * These can also be defined on the constructor being augmented with Attribute by defining the ATTRS property on the constructor."," * @param values {Object} The initial attribute values to apply (passed through to addAttrs)."," * These are not merged/cloned. The caller is responsible for isolating user provided values if required."," * @param lazy {boolean} Whether or not to add attributes lazily (passed through to addAttrs)."," */"," function AttributeCore(attrs, values, lazy) {"," // HACK: Fix #2531929"," // Complete hack, to make sure the first clone of a node value in IE doesn't doesn't hurt state - maintains 3.4.1 behavior."," // Too late in the release cycle to do anything about the core problem."," // The root issue is that cloning a Y.Node instance results in an object which barfs in IE, when you access it's properties (since 3.3.0)."," this._yuievt = null;",""," this._initAttrHost(attrs, values, lazy);"," }",""," /**"," *The value to return from an attribute setter in order to prevent the set from going through.
"," *"," *You can return this value from your setter if you wish to combine validator and setter"," * functionality into a single setter function, which either returns the massaged value to be stored or"," * AttributeCore.INVALID_VALUE to prevent invalid values from being stored.
"," *"," * @property INVALID_VALUE"," * @type Object"," * @static"," * @final"," */"," AttributeCore.INVALID_VALUE = {};"," INVALID_VALUE = AttributeCore.INVALID_VALUE;",""," /**"," * The list of properties which can be configured for"," * each attribute (e.g. setter, getter, writeOnce etc.)."," *"," * This property is used internally as a whitelist for faster"," * Y.mix operations."," *"," * @property _ATTR_CFG"," * @type Array"," * @static"," * @protected"," */"," AttributeCore._ATTR_CFG = [SETTER, GETTER, VALIDATOR, VALUE, VALUE_FN, WRITE_ONCE, READ_ONLY, LAZY_ADD, BYPASS_PROXY];",""," /**"," * Utility method to protect an attribute configuration hash, by merging the"," * entire object and the individual attr config objects."," *"," * @method protectAttrs"," * @static"," * @param {Object} attrs A hash of attribute to configuration object pairs."," * @return {Object} A protected version of the `attrs` argument."," */"," AttributeCore.protectAttrs = function (attrs) {"," if (attrs) {"," attrs = Y.merge(attrs);"," for (var attr in attrs) {"," if (attrs.hasOwnProperty(attr)) {"," attrs[attr] = Y.merge(attrs[attr]);"," }"," }"," }",""," return attrs;"," };",""," AttributeCore.prototype = {",""," /**"," * Constructor logic for attributes. Initializes the host state, and sets up the inital attributes passed to the"," * constructor."," *"," * @method _initAttrHost"," * @param attrs {Object} The attributes to add during construction (passed through to addAttrs)."," * These can also be defined on the constructor being augmented with Attribute by defining the ATTRS property on the constructor."," * @param values {Object} The initial attribute values to apply (passed through to addAttrs)."," * These are not merged/cloned. The caller is responsible for isolating user provided values if required."," * @param lazy {boolean} Whether or not to add attributes lazily (passed through to addAttrs)."," * @private"," */"," _initAttrHost : function(attrs, values, lazy) {"," this._state = new Y.State();"," this._initAttrs(attrs, values, lazy);"," },",""," /**"," *"," * Adds an attribute with the provided configuration to the host object."," *
"," *"," * The config argument object supports the following properties:"," *
"," *"," *A function, which will return the initial value to set on the attribute. This is useful"," * for cases where the attribute configuration is defined statically, but needs to"," * reference the host instance (\"this\") to obtain an initial value. If both the value and valueFn properties are defined,"," * the value returned by the valueFn has precedence over the value property, unless it returns undefined, in which"," * case the value property is used.
"," *"," *valueFn can also be set to a string, representing the name of the instance method to be used to retrieve the value.
"," *The writeOnce attribute can also be set to the string \"initOnly\","," * in which case the attribute can only be set during initialization"," * (when used with Base, this means it can only be set during construction)
"," *The setter function used to massage or normalize the value passed to the set method for the attribute."," * The value returned by the setter will be the final stored value. Returning"," * Attribute.INVALID_VALUE, from the setter will prevent"," * the value from being stored."," *
"," *"," *setter can also be set to a string, representing the name of the instance method to be used as the setter function.
"," *"," * The getter function used to massage or normalize the value returned by the get method for the attribute."," * The value returned by the getter function is the value which will be returned to the user when they"," * invoke get."," *
"," *"," *getter can also be set to a string, representing the name of the instance method to be used as the getter function.
"," *"," * The validator function invoked prior to setting the stored value. Returning"," * false from the validator function will prevent the value from being stored."," *
"," *"," *validator can also be set to a string, representing the name of the instance method to be used as the validator function.
"," *The setter, getter and validator are invoked with the value and name passed in as the first and second arguments, and with"," * the context (\"this\") set to the host object.
"," *"," *Configuration properties outside of the list mentioned above are considered private properties used internally by attribute,"," * and are not intended for public use.
"," *"," * @method addAttr"," *"," * @param {String} name The name of the attribute."," * @param {Object} config An object with attribute configuration property/value pairs, specifying the configuration for the attribute."," *"," *"," * NOTE: The configuration object is modified when adding an attribute, so if you need"," * to protect the original values, you will need to merge the object."," *
"," *"," * @param {boolean} lazy (optional) Whether or not to add this attribute lazily (on the first call to get/set)."," *"," * @return {Object} A reference to the host object."," *"," * @chainable"," */"," addAttr: function(name, config, lazy) {","",""," var host = this, // help compression"," state = host._state,"," value,"," hasValue;",""," config = config || {};",""," lazy = (LAZY_ADD in config) ? config[LAZY_ADD] : lazy;",""," if (lazy && !host.attrAdded(name)) {"," state.addAll(name, {"," lazy : config,"," added : true"," });"," } else {"," /*jshint maxlen:200*/",""," if (!host.attrAdded(name) || state.get(name, IS_LAZY_ADD)) {",""," hasValue = (VALUE in config);",""," /*jshint maxlen:150*/",""," if (hasValue) {"," // We'll go through set, don't want to set value in config directly"," value = config.value;"," delete config.value;"," }",""," config.added = true;"," config.initializing = true;",""," state.addAll(name, config);",""," if (hasValue) {"," // Go through set, so that raw values get normalized/validated"," host.set(name, value);"," }",""," state.remove(name, INITIALIZING);"," }"," }",""," return host;"," },",""," /**"," * Checks if the given attribute has been added to the host"," *"," * @method attrAdded"," * @param {String} name The name of the attribute to check."," * @return {boolean} true if an attribute with the given name has been added, false if it hasn't."," * This method will return true for lazily added attributes."," */"," attrAdded: function(name) {"," return !!this._state.get(name, ADDED);"," },",""," /**"," * Returns the current value of the attribute. If the attribute"," * has been configured with a 'getter' function, this method will delegate"," * to the 'getter' to obtain the value of the attribute."," *"," * @method get"," *"," * @param {String} name The name of the attribute. If the value of the attribute is an Object,"," * dot notation can be used to obtain the value of a property of the object (e.g.get(\"x.y.z\")
)"," *"," * @return {Any} The value of the attribute"," */"," get : function(name) {"," return this._getAttr(name);"," },",""," /**"," * Checks whether or not the attribute is one which has been"," * added lazily and still requires initialization."," *"," * @method _isLazyAttr"," * @private"," * @param {String} name The name of the attribute"," * @return {boolean} true if it's a lazily added attribute, false otherwise."," */"," _isLazyAttr: function(name) {"," return this._state.get(name, LAZY);"," },",""," /**"," * Finishes initializing an attribute which has been lazily added."," *"," * @method _addLazyAttr"," * @private"," * @param {Object} name The name of the attribute"," */"," _addLazyAttr: function(name) {"," var state = this._state,"," lazyCfg = state.get(name, LAZY);",""," state.add(name, IS_LAZY_ADD, true);"," state.remove(name, LAZY);"," this.addAttr(name, lazyCfg);"," },",""," /**"," * Sets the value of an attribute."," *"," * @method set"," * @chainable"," *"," * @param {String} name The name of the attribute. If the"," * current value of the attribute is an Object, dot notation can be used"," * to set the value of a property within the object (e.g. set(\"x.y.z\", 5)
)."," * @param {Any} value The value to set the attribute to."," * @param {Object} [opts] Optional data providing the circumstances for the change."," * @return {Object} A reference to the host object."," */"," set : function(name, val, opts) {"," return this._setAttr(name, val, opts);"," },",""," /**"," * Allows setting of readOnly/writeOnce attributes. See set for argument details."," *"," * @method _set"," * @protected"," * @chainable"," *"," * @param {String} name The name of the attribute."," * @param {Any} val The value to set the attribute to."," * @param {Object} [opts] Optional data providing the circumstances for the change."," * @return {Object} A reference to the host object."," */"," _set : function(name, val, opts) {"," return this._setAttr(name, val, opts, true);"," },",""," /**"," * Provides the common implementation for the public set and protected _set methods."," *"," * See set for argument details."," *"," * @method _setAttr"," * @protected"," * @chainable"," *"," * @param {String} name The name of the attribute."," * @param {Any} value The value to set the attribute to."," * @param {Object} [opts] Optional data providing the circumstances for the change."," * @param {boolean} force If true, allows the caller to set values for"," * readOnly or writeOnce attributes which have already been set."," *"," * @return {Object} A reference to the host object."," */"," _setAttr : function(name, val, opts, force) {"," var allowSet = true,"," state = this._state,"," stateProxy = this._stateProxy,"," cfg,"," initialSet,"," strPath,"," path,"," currVal,"," writeOnce,"," initializing;",""," if (name.indexOf(DOT) !== -1) {"," strPath = name;"," path = name.split(DOT);"," name = path.shift();"," }",""," if (this._isLazyAttr(name)) {"," this._addLazyAttr(name);"," }",""," cfg = state.getAll(name, true) || {};",""," initialSet = (!(VALUE in cfg));",""," if (stateProxy && name in stateProxy && !cfg._bypassProxy) {"," // TODO: Value is always set for proxy. Can we do any better? Maybe take a snapshot as the initial value for the first call to set?"," initialSet = false;"," }",""," writeOnce = cfg.writeOnce;"," initializing = cfg.initializing;",""," if (!initialSet && !force) {",""," if (writeOnce) {"," allowSet = false;"," }",""," if (cfg.readOnly) {"," allowSet = false;"," }"," }",""," if (!initializing && !force && writeOnce === INIT_ONLY) {"," allowSet = false;"," }",""," if (allowSet) {"," // Don't need currVal if initialSet (might fail in custom getter if it always expects a non-undefined/non-null value)"," if (!initialSet) {"," currVal = this.get(name);"," }",""," if (path) {"," val = O.setValue(Y.clone(currVal), path, val);",""," if (val === undefined) {"," allowSet = false;"," }"," }",""," if (allowSet) {"," opts = opts || {};"," if (!this._fireAttrChange || initializing) {"," this._setAttrVal(name, strPath, currVal, val, opts);"," } else {"," // HACK - no real reason core needs to know about _fireAttrChange, but"," // it adds fn hops if we want to break it out. Not sure it's worth it for this critical path"," this._fireAttrChange(name, strPath, currVal, val, opts);"," }"," }"," }",""," return this;"," },",""," /**"," * Provides the common implementation for the public get method,"," * allowing Attribute hosts to over-ride either method."," *"," * See get for argument details."," *"," * @method _getAttr"," * @protected"," * @chainable"," *"," * @param {String} name The name of the attribute."," * @return {Any} The value of the attribute."," */"," _getAttr : function(name) {"," var host = this, // help compression"," fullName = name,"," state = host._state,"," path,"," getter,"," val,"," cfg;",""," if (name.indexOf(DOT) !== -1) {"," path = name.split(DOT);"," name = path.shift();"," }",""," // On Demand - Should be rare - handles out of order valueFn references"," if (host._tCfgs && host._tCfgs[name]) {"," cfg = {};"," cfg[name] = host._tCfgs[name];"," delete host._tCfgs[name];"," host._addAttrs(cfg, host._tVals);"," }",""," // Lazy Init"," if (host._isLazyAttr(name)) {"," host._addLazyAttr(name);"," }",""," val = host._getStateVal(name);",""," getter = state.get(name, GETTER);",""," if (getter && !getter.call) {"," getter = this[getter];"," }",""," val = (getter) ? getter.call(host, val, fullName) : val;"," val = (path) ? O.getValue(val, path) : val;",""," return val;"," },",""," /**"," * Gets the stored value for the attribute, from either the"," * internal state object, or the state proxy if it exits"," *"," * @method _getStateVal"," * @private"," * @param {String} name The name of the attribute"," * @return {Any} The stored value of the attribute"," */"," _getStateVal : function(name) {"," var stateProxy = this._stateProxy;"," return stateProxy && (name in stateProxy) && !this._state.get(name, BYPASS_PROXY) ? stateProxy[name] : this._state.get(name, VALUE);"," },",""," /**"," * Sets the stored value for the attribute, in either the"," * internal state object, or the state proxy if it exits"," *"," * @method _setStateVal"," * @private"," * @param {String} name The name of the attribute"," * @param {Any} value The value of the attribute"," */"," _setStateVal : function(name, value) {"," var stateProxy = this._stateProxy;"," if (stateProxy && (name in stateProxy) && !this._state.get(name, BYPASS_PROXY)) {"," stateProxy[name] = value;"," } else {"," this._state.add(name, VALUE, value);"," }"," },",""," /**"," * Updates the stored value of the attribute in the privately held State object,"," * if validation and setter passes."," *"," * @method _setAttrVal"," * @private"," * @param {String} attrName The attribute name."," * @param {String} subAttrName The sub-attribute name, if setting a sub-attribute property (\"x.y.z\")."," * @param {Any} prevVal The currently stored value of the attribute."," * @param {Any} newVal The value which is going to be stored."," * @param {Object} [opts] Optional data providing the circumstances for the change."," *"," * @return {booolean} true if the new attribute value was stored, false if not."," */"," _setAttrVal : function(attrName, subAttrName, prevVal, newVal, opts) {",""," var host = this,"," allowSet = true,"," cfg = this._state.getAll(attrName, true) || {},"," validator = cfg.validator,"," setter = cfg.setter,"," initializing = cfg.initializing,"," prevRawVal = this._getStateVal(attrName),"," name = subAttrName || attrName,"," retVal,"," valid;",""," if (validator) {"," if (!validator.call) {"," // Assume string - trying to keep critical path tight, so avoiding Lang check"," validator = this[validator];"," }"," if (validator) {"," valid = validator.call(host, newVal, name, opts);",""," if (!valid && initializing) {"," newVal = cfg.defaultValue;"," valid = true; // Assume it's valid, for perf."," }"," }"," }",""," if (!validator || valid) {"," if (setter) {"," if (!setter.call) {"," // Assume string - trying to keep critical path tight, so avoiding Lang check"," setter = this[setter];"," }"," if (setter) {"," retVal = setter.call(host, newVal, name, opts);",""," if (retVal === INVALID_VALUE) {"," allowSet = false;"," } else if (retVal !== undefined){"," newVal = retVal;"," }"," }"," }",""," if (allowSet) {"," if(!subAttrName && (newVal === prevRawVal) && !Lang.isObject(newVal)) {"," allowSet = false;"," } else {"," // Store value"," if (!(INIT_VALUE in cfg)) {"," cfg.initValue = newVal;"," }"," host._setStateVal(attrName, newVal);"," }"," }",""," } else {"," allowSet = false;"," }",""," return allowSet;"," },",""," /**"," * Sets multiple attribute values."," *"," * @method setAttrs"," * @param {Object} attrs An object with attributes name/value pairs."," * @param {Object} [opts] Optional data providing the circumstances for the change."," * @return {Object} A reference to the host object."," * @chainable"," */"," setAttrs : function(attrs, opts) {"," return this._setAttrs(attrs, opts);"," },",""," /**"," * Implementation behind the public setAttrs method, to set multiple attribute values."," *"," * @method _setAttrs"," * @protected"," * @param {Object} attrs An object with attributes name/value pairs."," * @param {Object} [opts] Optional data providing the circumstances for the change"," * @return {Object} A reference to the host object."," * @chainable"," */"," _setAttrs : function(attrs, opts) {"," var attr;"," for (attr in attrs) {"," if ( attrs.hasOwnProperty(attr) ) {"," this.set(attr, attrs[attr], opts);"," }"," }"," return this;"," },",""," /**"," * Gets multiple attribute values."," *"," * @method getAttrs"," * @param {Array | boolean} attrs Optional. An array of attribute names. If omitted, all attribute values are"," * returned. If set to true, all attributes modified from their initial values are returned."," * @return {Object} An object with attribute name/value pairs."," */"," getAttrs : function(attrs) {"," return this._getAttrs(attrs);"," },",""," /**"," * Implementation behind the public getAttrs method, to get multiple attribute values."," *"," * @method _getAttrs"," * @protected"," * @param {Array | boolean} attrs Optional. An array of attribute names. If omitted, all attribute values are"," * returned. If set to true, all attributes modified from their initial values are returned."," * @return {Object} An object with attribute name/value pairs."," */"," _getAttrs : function(attrs) {"," var obj = {},"," attr, i, len,"," modifiedOnly = (attrs === true);",""," // TODO - figure out how to get all \"added\""," if (!attrs || modifiedOnly) {"," attrs = O.keys(this._state.data);"," }",""," for (i = 0, len = attrs.length; i < len; i++) {"," attr = attrs[i];",""," if (!modifiedOnly || this._getStateVal(attr) != this._state.get(attr, INIT_VALUE)) {"," // Go through get, to honor cloning/normalization"," obj[attr] = this.get(attr);"," }"," }",""," return obj;"," },",""," /**"," * Configures a group of attributes, and sets initial values."," *"," * "," * NOTE: This method does not isolate the configuration object by merging/cloning."," * The caller is responsible for merging/cloning the configuration object if required."," *
"," *"," * @method addAttrs"," * @chainable"," *"," * @param {Object} cfgs An object with attribute name/configuration pairs."," * @param {Object} values An object with attribute name/value pairs, defining the initial values to apply."," * Values defined in the cfgs argument will be over-written by values in this argument unless defined as read only."," * @param {boolean} lazy Whether or not to delay the intialization of these attributes until the first call to get/set."," * Individual attributes can over-ride this behavior by defining a lazyAdd configuration property in their configuration."," * See addAttr."," *"," * @return {Object} A reference to the host object."," */"," addAttrs : function(cfgs, values, lazy) {"," var host = this; // help compression"," if (cfgs) {"," host._tCfgs = cfgs;"," host._tVals = host._normAttrVals(values);"," host._addAttrs(cfgs, host._tVals, lazy);"," host._tCfgs = host._tVals = null;"," }",""," return host;"," },",""," /**"," * Implementation behind the public addAttrs method."," *"," * This method is invoked directly by get if it encounters a scenario"," * in which an attribute's valueFn attempts to obtain the"," * value an attribute in the same group of attributes, which has not yet"," * been added (on demand initialization)."," *"," * @method _addAttrs"," * @private"," * @param {Object} cfgs An object with attribute name/configuration pairs."," * @param {Object} values An object with attribute name/value pairs, defining the initial values to apply."," * Values defined in the cfgs argument will be over-written by values in this argument unless defined as read only."," * @param {boolean} lazy Whether or not to delay the intialization of these attributes until the first call to get/set."," * Individual attributes can over-ride this behavior by defining a lazyAdd configuration property in their configuration."," * See addAttr."," */"," _addAttrs : function(cfgs, values, lazy) {"," var host = this, // help compression"," attr,"," attrCfg,"," value;",""," for (attr in cfgs) {"," if (cfgs.hasOwnProperty(attr)) {",""," // Not Merging. Caller is responsible for isolating configs"," attrCfg = cfgs[attr];"," attrCfg.defaultValue = attrCfg.value;",""," // Handle simple, complex and user values, accounting for read-only"," value = host._getAttrInitVal(attr, attrCfg, host._tVals);",""," if (value !== undefined) {"," attrCfg.value = value;"," }",""," if (host._tCfgs[attr]) {"," delete host._tCfgs[attr];"," }",""," host.addAttr(attr, attrCfg, lazy);"," }"," }"," },",""," /**"," * Utility method to protect an attribute configuration"," * hash, by merging the entire object and the individual"," * attr config objects."," *"," * @method _protectAttrs"," * @protected"," * @param {Object} attrs A hash of attribute to configuration object pairs."," * @return {Object} A protected version of the attrs argument."," * @deprecated Use `AttributeCore.protectAttrs()` or"," * `Attribute.protectAttrs()` which are the same static utility method."," */"," _protectAttrs : AttributeCore.protectAttrs,",""," /**"," * Utility method to normalize attribute values. The base implementation"," * simply merges the hash to protect the original."," *"," * @method _normAttrVals"," * @param {Object} valueHash An object with attribute name/value pairs"," *"," * @return {Object} An object literal with 2 properties - \"simple\" and \"complex\","," * containing simple and complex attribute values respectively keyed"," * by the top level attribute name, or null, if valueHash is falsey."," *"," * @private"," */"," _normAttrVals : function(valueHash) {"," var vals = {},"," subvals = {},"," path,"," attr,"," v, k;",""," if (valueHash) {"," for (k in valueHash) {"," if (valueHash.hasOwnProperty(k)) {"," if (k.indexOf(DOT) !== -1) {"," path = k.split(DOT);"," attr = path.shift();"," v = subvals[attr] = subvals[attr] || [];"," v[v.length] = {"," path : path,"," value: valueHash[k]"," };"," } else {"," vals[k] = valueHash[k];"," }"," }"," }"," return { simple:vals, complex:subvals };"," } else {"," return null;"," }"," },",""," /**"," * Returns the initial value of the given attribute from"," * either the default configuration provided, or the"," * over-ridden value if it exists in the set of initValues"," * provided and the attribute is not read-only."," *"," * @param {String} attr The name of the attribute"," * @param {Object} cfg The attribute configuration object"," * @param {Object} initValues The object with simple and complex attribute name/value pairs returned from _normAttrVals"," *"," * @return {Any} The initial value of the attribute."," *"," * @method _getAttrInitVal"," * @private"," */"," _getAttrInitVal : function(attr, cfg, initValues) {"," var val = cfg.value,"," valFn = cfg.valueFn,"," tmpVal,"," initValSet = false,"," simple,"," complex,"," i,"," l,"," path,"," subval,"," subvals;",""," if (!cfg.readOnly && initValues) {"," // Simple Attributes"," simple = initValues.simple;"," if (simple && simple.hasOwnProperty(attr)) {"," val = simple[attr];"," initValSet = true;"," }"," }",""," if (valFn && !initValSet) {"," if (!valFn.call) {"," valFn = this[valFn];"," }"," if (valFn) {"," tmpVal = valFn.call(this, attr);"," val = tmpVal;"," }"," }",""," if (!cfg.readOnly && initValues) {",""," // Complex Attributes (complex values applied, after simple, in case both are set)"," complex = initValues.complex;",""," if (complex && complex.hasOwnProperty(attr) && (val !== undefined) && (val !== null)) {"," subvals = complex[attr];"," for (i = 0, l = subvals.length; i < l; ++i) {"," path = subvals[i].path;"," subval = subvals[i].value;"," O.setValue(val, path, subval);"," }"," }"," }",""," return val;"," },",""," /**"," * Utility method to set up initial attributes defined during construction,"," * either through the constructor.ATTRS property, or explicitly passed in."," *"," * @method _initAttrs"," * @protected"," * @param attrs {Object} The attributes to add during construction (passed through to addAttrs)."," * These can also be defined on the constructor being augmented with Attribute by defining the ATTRS property on the constructor."," * @param values {Object} The initial attribute values to apply (passed through to addAttrs)."," * These are not merged/cloned. The caller is responsible for isolating user provided values if required."," * @param lazy {boolean} Whether or not to add attributes lazily (passed through to addAttrs)."," */"," _initAttrs : function(attrs, values, lazy) {"," // ATTRS support for Node, which is not Base based"," attrs = attrs || this.constructor.ATTRS;",""," var Base = Y.Base,"," BaseCore = Y.BaseCore,"," baseInst = (Base && Y.instanceOf(this, Base)),"," baseCoreInst = (!baseInst && BaseCore && Y.instanceOf(this, BaseCore));",""," if (attrs && !baseInst && !baseCoreInst) {"," this.addAttrs(Y.AttributeCore.protectAttrs(attrs), values, lazy);"," }"," }"," };",""," Y.AttributeCore = AttributeCore;","","","}, '@VERSION@', {\"requires\": [\"oop\"]});"]; -_yuitest_coverage["build/attribute-core/attribute-core.js"].lines = {"1":0,"14":0,"19":0,"22":0,"33":0,"35":0,"36":0,"39":0,"50":0,"53":0,"54":0,"57":0,"58":0,"59":0,"72":0,"74":0,"75":0,"87":0,"89":0,"90":0,"92":0,"93":0,"96":0,"97":0,"111":0,"113":0,"114":0,"132":0,"135":0,"136":0,"137":0,"138":0,"140":0,"141":0,"142":0,"147":0,"168":0,"225":0,"230":0,"232":0,"247":0,"248":0,"262":0,"273":0,"274":0,"275":0,"276":0,"277":0,"278":0,"283":0,"286":0,"301":0,"302":0,"406":0,"411":0,"413":0,"415":0,"416":0,"423":0,"425":0,"429":0,"431":0,"432":0,"435":0,"436":0,"438":0,"440":0,"442":0,"445":0,"449":0,"461":0,"477":0,"490":0,"501":0,"504":0,"505":0,"506":0,"523":0,"539":0,"560":0,"571":0,"572":0,"573":0,"574":0,"577":0,"578":0,"581":0,"583":0,"585":0,"587":0,"590":0,"591":0,"593":0,"595":0,"596":0,"599":0,"600":0,"604":0,"605":0,"608":0,"610":0,"611":0,"614":0,"615":0,"617":0,"618":0,"622":0,"623":0,"624":0,"625":0,"629":0,"634":0,"651":0,"659":0,"660":0,"661":0,"665":0,"666":0,"667":0,"668":0,"669":0,"673":0,"674":0,"677":0,"679":0,"681":0,"682":0,"685":0,"686":0,"688":0,"701":0,"702":0,"715":0,"716":0,"717":0,"719":0,"739":0,"750":0,"751":0,"753":0,"755":0,"756":0,"758":0,"759":0,"760":0,"765":0,"766":0,"767":0,"769":0,"771":0,"772":0,"774":0,"775":0,"776":0,"777":0,"782":0,"783":0,"784":0,"787":0,"788":0,"790":0,"795":0,"798":0,"811":0,"825":0,"826":0,"827":0,"828":0,"831":0,"843":0,"856":0,"861":0,"862":0,"865":0,"866":0,"868":0,"870":0,"874":0,"898":0,"899":0,"900":0,"901":0,"902":0,"903":0,"906":0,"927":0,"932":0,"933":0,"936":0,"937":0,"940":0,"942":0,"943":0,"946":0,"947":0,"950":0,"983":0,"989":0,"990":0,"991":0,"992":0,"993":0,"994":0,"995":0,"996":0,"1001":0,"1005":0,"1007":0,"1027":0,"1039":0,"1041":0,"1042":0,"1043":0,"1044":0,"1048":0,"1049":0,"1050":0,"1052":0,"1053":0,"1054":0,"1058":0,"1061":0,"1063":0,"1064":0,"1065":0,"1066":0,"1067":0,"1068":0,"1073":0,"1090":0,"1092":0,"1097":0,"1098":0,"1103":0}; -_yuitest_coverage["build/attribute-core/attribute-core.js"].functions = {"State:14":0,"add:32":0,"addAll:49":0,"remove:71":0,"(anonymous 2):96":0,"removeAll:86":0,"get:110":0,"getAll:131":0,"AttributeCore:225":0,"protectAttrs:273":0,"_initAttrHost:300":0,"addAttr:403":0,"attrAdded:460":0,"get:476":0,"_isLazyAttr:489":0,"_addLazyAttr:500":0,"set:522":0,"_set:538":0,"_setAttr:559":0,"_getAttr:650":0,"_getStateVal:700":0,"_setStateVal:714":0,"_setAttrVal:737":0,"setAttrs:810":0,"_setAttrs:824":0,"getAttrs:842":0,"_getAttrs:855":0,"addAttrs:897":0,"_addAttrs:926":0,"_normAttrVals:982":0,"_getAttrInitVal:1026":0,"_initAttrs:1088":0,"(anonymous 1):1":0}; -_yuitest_coverage["build/attribute-core/attribute-core.js"].coveredLines = 234; +_yuitest_coverage["build/attribute-core/attribute-core.js"].code=["YUI.add('attribute-core', function (Y, NAME) {",""," /**"," * The State class maintains state for a collection of named items, with"," * a varying number of properties defined."," *"," * It avoids the need to create a separate class for the item, and separate instances"," * of these classes for each item, by storing the state in a 2 level hash table,"," * improving performance when the number of items is likely to be large."," *"," * @constructor"," * @class State"," */"," Y.State = function() {"," /**"," * Hash of attributes"," * @property data"," */"," this.data = {};"," };",""," Y.State.prototype = {",""," /**"," * Adds a property to an item."," *"," * @method add"," * @param name {String} The name of the item."," * @param key {String} The name of the property."," * @param val {Any} The value of the property."," */"," add: function(name, key, val) {"," var item = this.data[name];",""," if (!item) {"," item = this.data[name] = {};"," }",""," item[key] = val;"," },",""," /**"," * Adds multiple properties to an item."," *"," * @method addAll"," * @param name {String} The name of the item."," * @param obj {Object} A hash of property/value pairs."," */"," addAll: function(name, obj) {"," var item = this.data[name],"," key;",""," if (!item) {"," item = this.data[name] = {};"," }",""," for (key in obj) {"," if (obj.hasOwnProperty(key)) {"," item[key] = obj[key];"," }"," }"," },",""," /**"," * Removes a property from an item."," *"," * @method remove"," * @param name {String} The name of the item."," * @param key {String} The property to remove."," */"," remove: function(name, key) {"," var item = this.data[name];",""," if (item) {"," delete item[key];"," }"," },",""," /**"," * Removes multiple properties from an item, or removes the item completely."," *"," * @method removeAll"," * @param name {String} The name of the item."," * @param obj {Object|Array} Collection of properties to delete. If not provided, the entire item is removed."," */"," removeAll: function(name, obj) {"," var data;",""," if (!obj) {"," data = this.data;",""," if (name in data) {"," delete data[name];"," }"," } else {"," Y.each(obj, function(value, key) {"," this.remove(name, typeof key === 'string' ? key : value);"," }, this);"," }"," },",""," /**"," * For a given item, returns the value of the property requested, or undefined if not found."," *"," * @method get"," * @param name {String} The name of the item"," * @param key {String} Optional. The property value to retrieve."," * @return {Any} The value of the supplied property."," */"," get: function(name, key) {"," var item = this.data[name];",""," if (item) {"," return item[key];"," }"," },",""," /**"," * For the given item, returns an object with all of the"," * item's property/value pairs. By default the object returned"," * is a shallow copy of the stored data, but passing in true"," * as the second parameter will return a reference to the stored"," * data."," *"," * @method getAll"," * @param name {String} The name of the item"," * @param reference {boolean} true, if you want a reference to the stored"," * object"," * @return {Object} An object with property/value pairs for the item."," */"," getAll : function(name, reference) {"," var item = this.data[name],"," key, obj;",""," if (reference) {"," obj = item;"," } else if (item) {"," obj = {};",""," for (key in item) {"," if (item.hasOwnProperty(key)) {"," obj[key] = item[key];"," }"," }"," }",""," return obj;"," }"," };"," /**"," * The attribute module provides an augmentable Attribute implementation, which"," * adds configurable attributes and attribute change events to the class being"," * augmented. It also provides a State class, which is used internally by Attribute,"," * but can also be used independently to provide a name/property/value data structure to"," * store state."," *"," * @module attribute"," */",""," /**"," * The attribute-core submodule provides the lightest level of attribute handling support"," * without Attribute change events, or lesser used methods such as reset(), modifyAttrs(),"," * and removeAttr()."," *"," * @module attribute"," * @submodule attribute-core"," */"," var O = Y.Object,"," Lang = Y.Lang,",""," DOT = \".\",",""," // Externally configurable props"," GETTER = \"getter\","," SETTER = \"setter\","," READ_ONLY = \"readOnly\","," WRITE_ONCE = \"writeOnce\","," INIT_ONLY = \"initOnly\","," VALIDATOR = \"validator\","," VALUE = \"value\","," VALUE_FN = \"valueFn\","," LAZY_ADD = \"lazyAdd\",",""," // Used for internal state management"," ADDED = \"added\","," BYPASS_PROXY = \"_bypassProxy\","," INITIALIZING = \"initializing\","," INIT_VALUE = \"initValue\","," LAZY = \"lazy\","," IS_LAZY_ADD = \"isLazyAdd\",",""," INVALID_VALUE;",""," /**"," *"," * AttributeCore provides the lightest level of configurable attribute support. It is designed to be"," * augmented on to a host class, and provides the host with the ability to configure"," * attributes to store and retrieve state, but without support for attribute change events."," *
"," *For example, attributes added to the host can be configured:
"," *See the addAttr method, for the complete set of configuration"," * options available for attributes.
"," *"," *Object/Classes based on AttributeCore can augment AttributeObservable"," * (with true for overwrite) and AttributeExtras to add attribute event and"," * additional, less commonly used attribute methods, such as `modifyAttr`, `removeAttr` and `reset`.
"," *"," * @class AttributeCore"," * @param attrs {Object} The attributes to add during construction (passed through to addAttrs)."," * These can also be defined on the constructor being augmented with Attribute by defining the ATTRS property on the constructor."," * @param values {Object} The initial attribute values to apply (passed through to addAttrs)."," * These are not merged/cloned. The caller is responsible for isolating user provided values if required."," * @param lazy {boolean} Whether or not to add attributes lazily (passed through to addAttrs)."," */"," function AttributeCore(attrs, values, lazy) {"," // HACK: Fix #2531929"," // Complete hack, to make sure the first clone of a node value in IE doesn't doesn't hurt state - maintains 3.4.1 behavior."," // Too late in the release cycle to do anything about the core problem."," // The root issue is that cloning a Y.Node instance results in an object which barfs in IE, when you access it's properties (since 3.3.0)."," this._yuievt = null;",""," this._initAttrHost(attrs, values, lazy);"," }",""," /**"," *The value to return from an attribute setter in order to prevent the set from going through.
"," *"," *You can return this value from your setter if you wish to combine validator and setter"," * functionality into a single setter function, which either returns the massaged value to be stored or"," * AttributeCore.INVALID_VALUE to prevent invalid values from being stored.
"," *"," * @property INVALID_VALUE"," * @type Object"," * @static"," * @final"," */"," AttributeCore.INVALID_VALUE = {};"," INVALID_VALUE = AttributeCore.INVALID_VALUE;",""," /**"," * The list of properties which can be configured for"," * each attribute (e.g. setter, getter, writeOnce etc.)."," *"," * This property is used internally as a whitelist for faster"," * Y.mix operations."," *"," * @property _ATTR_CFG"," * @type Array"," * @static"," * @protected"," */"," AttributeCore._ATTR_CFG = [SETTER, GETTER, VALIDATOR, VALUE, VALUE_FN, WRITE_ONCE, READ_ONLY, LAZY_ADD, BYPASS_PROXY];",""," /**"," * Utility method to protect an attribute configuration hash, by merging the"," * entire object and the individual attr config objects."," *"," * @method protectAttrs"," * @static"," * @param {Object} attrs A hash of attribute to configuration object pairs."," * @return {Object} A protected version of the `attrs` argument."," */"," AttributeCore.protectAttrs = function (attrs) {"," if (attrs) {"," attrs = Y.merge(attrs);"," for (var attr in attrs) {"," if (attrs.hasOwnProperty(attr)) {"," attrs[attr] = Y.merge(attrs[attr]);"," }"," }"," }",""," return attrs;"," };",""," AttributeCore.prototype = {",""," /**"," * Constructor logic for attributes. Initializes the host state, and sets up the inital attributes passed to the"," * constructor."," *"," * @method _initAttrHost"," * @param attrs {Object} The attributes to add during construction (passed through to addAttrs)."," * These can also be defined on the constructor being augmented with Attribute by defining the ATTRS property on the constructor."," * @param values {Object} The initial attribute values to apply (passed through to addAttrs)."," * These are not merged/cloned. The caller is responsible for isolating user provided values if required."," * @param lazy {boolean} Whether or not to add attributes lazily (passed through to addAttrs)."," * @private"," */"," _initAttrHost : function(attrs, values, lazy) {"," this._state = new Y.State();"," this._initAttrs(attrs, values, lazy);"," },",""," /**"," *"," * Adds an attribute with the provided configuration to the host object."," *
"," *"," * The config argument object supports the following properties:"," *
"," *"," *A function, which will return the initial value to set on the attribute. This is useful"," * for cases where the attribute configuration is defined statically, but needs to"," * reference the host instance (\"this\") to obtain an initial value. If both the value and valueFn properties are defined,"," * the value returned by the valueFn has precedence over the value property, unless it returns undefined, in which"," * case the value property is used.
"," *"," *valueFn can also be set to a string, representing the name of the instance method to be used to retrieve the value.
"," *The writeOnce attribute can also be set to the string \"initOnly\","," * in which case the attribute can only be set during initialization"," * (when used with Base, this means it can only be set during construction)
"," *The setter function used to massage or normalize the value passed to the set method for the attribute."," * The value returned by the setter will be the final stored value. Returning"," * Attribute.INVALID_VALUE, from the setter will prevent"," * the value from being stored."," *
"," *"," *setter can also be set to a string, representing the name of the instance method to be used as the setter function.
"," *"," * The getter function used to massage or normalize the value returned by the get method for the attribute."," * The value returned by the getter function is the value which will be returned to the user when they"," * invoke get."," *
"," *"," *getter can also be set to a string, representing the name of the instance method to be used as the getter function.
"," *"," * The validator function invoked prior to setting the stored value. Returning"," * false from the validator function will prevent the value from being stored."," *
"," *"," *validator can also be set to a string, representing the name of the instance method to be used as the validator function.
"," *The setter, getter and validator are invoked with the value and name passed in as the first and second arguments, and with"," * the context (\"this\") set to the host object.
"," *"," *Configuration properties outside of the list mentioned above are considered private properties used internally by attribute,"," * and are not intended for public use.
"," *"," * @method addAttr"," *"," * @param {String} name The name of the attribute."," * @param {Object} config An object with attribute configuration property/value pairs, specifying the configuration for the attribute."," *"," *"," * NOTE: The configuration object is modified when adding an attribute, so if you need"," * to protect the original values, you will need to merge the object."," *
"," *"," * @param {boolean} lazy (optional) Whether or not to add this attribute lazily (on the first call to get/set)."," *"," * @return {Object} A reference to the host object."," *"," * @chainable"," */"," addAttr: function(name, config, lazy) {","",""," var host = this, // help compression"," state = host._state,"," value,"," hasValue;",""," config = config || {};",""," lazy = (LAZY_ADD in config) ? config[LAZY_ADD] : lazy;",""," if (lazy && !host.attrAdded(name)) {"," state.addAll(name, {"," lazy : config,"," added : true"," });"," } else {"," /*jshint maxlen:200*/",""," if (!host.attrAdded(name) || state.get(name, IS_LAZY_ADD)) {",""," hasValue = (VALUE in config);",""," /*jshint maxlen:150*/",""," if (hasValue) {"," // We'll go through set, don't want to set value in config directly"," value = config.value;"," delete config.value;"," }",""," config.added = true;"," config.initializing = true;",""," state.addAll(name, config);",""," if (hasValue) {"," // Go through set, so that raw values get normalized/validated"," host.set(name, value);"," }",""," state.remove(name, INITIALIZING);"," }"," }",""," return host;"," },",""," /**"," * Checks if the given attribute has been added to the host"," *"," * @method attrAdded"," * @param {String} name The name of the attribute to check."," * @return {boolean} true if an attribute with the given name has been added, false if it hasn't."," * This method will return true for lazily added attributes."," */"," attrAdded: function(name) {"," return !!this._state.get(name, ADDED);"," },",""," /**"," * Returns the current value of the attribute. If the attribute"," * has been configured with a 'getter' function, this method will delegate"," * to the 'getter' to obtain the value of the attribute."," *"," * @method get"," *"," * @param {String} name The name of the attribute. If the value of the attribute is an Object,"," * dot notation can be used to obtain the value of a property of the object (e.g.get(\"x.y.z\")
)"," *"," * @return {Any} The value of the attribute"," */"," get : function(name) {"," return this._getAttr(name);"," },",""," /**"," * Checks whether or not the attribute is one which has been"," * added lazily and still requires initialization."," *"," * @method _isLazyAttr"," * @private"," * @param {String} name The name of the attribute"," * @return {boolean} true if it's a lazily added attribute, false otherwise."," */"," _isLazyAttr: function(name) {"," return this._state.get(name, LAZY);"," },",""," /**"," * Finishes initializing an attribute which has been lazily added."," *"," * @method _addLazyAttr"," * @private"," * @param {Object} name The name of the attribute"," */"," _addLazyAttr: function(name) {"," var state = this._state,"," lazyCfg = state.get(name, LAZY);",""," state.add(name, IS_LAZY_ADD, true);"," state.remove(name, LAZY);"," this.addAttr(name, lazyCfg);"," },",""," /**"," * Sets the value of an attribute."," *"," * @method set"," * @chainable"," *"," * @param {String} name The name of the attribute. If the"," * current value of the attribute is an Object, dot notation can be used"," * to set the value of a property within the object (e.g. set(\"x.y.z\", 5)
)."," * @param {Any} value The value to set the attribute to."," * @param {Object} [opts] Optional data providing the circumstances for the change."," * @return {Object} A reference to the host object."," */"," set : function(name, val, opts) {"," return this._setAttr(name, val, opts);"," },",""," /**"," * Allows setting of readOnly/writeOnce attributes. See set for argument details."," *"," * @method _set"," * @protected"," * @chainable"," *"," * @param {String} name The name of the attribute."," * @param {Any} val The value to set the attribute to."," * @param {Object} [opts] Optional data providing the circumstances for the change."," * @return {Object} A reference to the host object."," */"," _set : function(name, val, opts) {"," return this._setAttr(name, val, opts, true);"," },",""," /**"," * Provides the common implementation for the public set and protected _set methods."," *"," * See set for argument details."," *"," * @method _setAttr"," * @protected"," * @chainable"," *"," * @param {String} name The name of the attribute."," * @param {Any} value The value to set the attribute to."," * @param {Object} [opts] Optional data providing the circumstances for the change."," * @param {boolean} force If true, allows the caller to set values for"," * readOnly or writeOnce attributes which have already been set."," *"," * @return {Object} A reference to the host object."," */"," _setAttr : function(name, val, opts, force) {"," var allowSet = true,"," state = this._state,"," stateProxy = this._stateProxy,"," cfg,"," initialSet,"," strPath,"," path,"," currVal,"," writeOnce,"," initializing;",""," if (name.indexOf(DOT) !== -1) {"," strPath = name;"," path = name.split(DOT);"," name = path.shift();"," }",""," if (this._isLazyAttr(name)) {"," this._addLazyAttr(name);"," }",""," cfg = state.getAll(name, true) || {};",""," initialSet = (!(VALUE in cfg));",""," if (stateProxy && name in stateProxy && !cfg._bypassProxy) {"," // TODO: Value is always set for proxy. Can we do any better? Maybe take a snapshot as the initial value for the first call to set?"," initialSet = false;"," }",""," writeOnce = cfg.writeOnce;"," initializing = cfg.initializing;",""," if (!initialSet && !force) {",""," if (writeOnce) {"," allowSet = false;"," }",""," if (cfg.readOnly) {"," allowSet = false;"," }"," }",""," if (!initializing && !force && writeOnce === INIT_ONLY) {"," allowSet = false;"," }",""," if (allowSet) {"," // Don't need currVal if initialSet (might fail in custom getter if it always expects a non-undefined/non-null value)"," if (!initialSet) {"," currVal = this.get(name);"," }",""," if (path) {"," val = O.setValue(Y.clone(currVal), path, val);",""," if (val === undefined) {"," allowSet = false;"," }"," }",""," if (allowSet) {"," opts = opts || {};"," if (!this._fireAttrChange || initializing) {"," this._setAttrVal(name, strPath, currVal, val, opts);"," } else {"," // HACK - no real reason core needs to know about _fireAttrChange, but"," // it adds fn hops if we want to break it out. Not sure it's worth it for this critical path"," this._fireAttrChange(name, strPath, currVal, val, opts);"," }"," }"," }",""," return this;"," },",""," /**"," * Provides the common implementation for the public get method,"," * allowing Attribute hosts to over-ride either method."," *"," * See get for argument details."," *"," * @method _getAttr"," * @protected"," * @chainable"," *"," * @param {String} name The name of the attribute."," * @return {Any} The value of the attribute."," */"," _getAttr : function(name) {"," var host = this, // help compression"," fullName = name,"," state = host._state,"," path,"," getter,"," val,"," cfg;",""," if (name.indexOf(DOT) !== -1) {"," path = name.split(DOT);"," name = path.shift();"," }",""," // On Demand - Should be rare - handles out of order valueFn references"," if (host._tCfgs && host._tCfgs[name]) {"," cfg = {};"," cfg[name] = host._tCfgs[name];"," delete host._tCfgs[name];"," host._addAttrs(cfg, host._tVals);"," }",""," // Lazy Init"," if (host._isLazyAttr(name)) {"," host._addLazyAttr(name);"," }",""," val = host._getStateVal(name);",""," getter = state.get(name, GETTER);",""," if (getter && !getter.call) {"," getter = this[getter];"," }",""," val = (getter) ? getter.call(host, val, fullName) : val;"," val = (path) ? O.getValue(val, path) : val;",""," return val;"," },",""," /**"," * Gets the stored value for the attribute, from either the"," * internal state object, or the state proxy if it exits"," *"," * @method _getStateVal"," * @private"," * @param {String} name The name of the attribute"," * @return {Any} The stored value of the attribute"," */"," _getStateVal : function(name) {"," var stateProxy = this._stateProxy;"," return stateProxy && (name in stateProxy) && !this._state.get(name, BYPASS_PROXY) ? stateProxy[name] : this._state.get(name, VALUE);"," },",""," /**"," * Sets the stored value for the attribute, in either the"," * internal state object, or the state proxy if it exits"," *"," * @method _setStateVal"," * @private"," * @param {String} name The name of the attribute"," * @param {Any} value The value of the attribute"," */"," _setStateVal : function(name, value) {"," var stateProxy = this._stateProxy;"," if (stateProxy && (name in stateProxy) && !this._state.get(name, BYPASS_PROXY)) {"," stateProxy[name] = value;"," } else {"," this._state.add(name, VALUE, value);"," }"," },",""," /**"," * Updates the stored value of the attribute in the privately held State object,"," * if validation and setter passes."," *"," * @method _setAttrVal"," * @private"," * @param {String} attrName The attribute name."," * @param {String} subAttrName The sub-attribute name, if setting a sub-attribute property (\"x.y.z\")."," * @param {Any} prevVal The currently stored value of the attribute."," * @param {Any} newVal The value which is going to be stored."," * @param {Object} [opts] Optional data providing the circumstances for the change."," *"," * @return {booolean} true if the new attribute value was stored, false if not."," */"," _setAttrVal : function(attrName, subAttrName, prevVal, newVal, opts) {",""," var host = this,"," allowSet = true,"," cfg = this._state.getAll(attrName, true) || {},"," validator = cfg.validator,"," setter = cfg.setter,"," initializing = cfg.initializing,"," prevRawVal = this._getStateVal(attrName),"," name = subAttrName || attrName,"," retVal,"," valid;",""," if (validator) {"," if (!validator.call) {"," // Assume string - trying to keep critical path tight, so avoiding Lang check"," validator = this[validator];"," }"," if (validator) {"," valid = validator.call(host, newVal, name, opts);",""," if (!valid && initializing) {"," newVal = cfg.defaultValue;"," valid = true; // Assume it's valid, for perf."," }"," }"," }",""," if (!validator || valid) {"," if (setter) {"," if (!setter.call) {"," // Assume string - trying to keep critical path tight, so avoiding Lang check"," setter = this[setter];"," }"," if (setter) {"," retVal = setter.call(host, newVal, name, opts);",""," if (retVal === INVALID_VALUE) {"," if (initializing) {"," newVal = cfg.defaultValue;"," } else {"," allowSet = false;"," }"," } else if (retVal !== undefined){"," newVal = retVal;"," }"," }"," }",""," if (allowSet) {"," if(!subAttrName && (newVal === prevRawVal) && !Lang.isObject(newVal)) {"," allowSet = false;"," } else {"," // Store value"," if (!(INIT_VALUE in cfg)) {"," cfg.initValue = newVal;"," }"," host._setStateVal(attrName, newVal);"," }"," }",""," } else {"," allowSet = false;"," }",""," return allowSet;"," },",""," /**"," * Sets multiple attribute values."," *"," * @method setAttrs"," * @param {Object} attrs An object with attributes name/value pairs."," * @param {Object} [opts] Optional data providing the circumstances for the change."," * @return {Object} A reference to the host object."," * @chainable"," */"," setAttrs : function(attrs, opts) {"," return this._setAttrs(attrs, opts);"," },",""," /**"," * Implementation behind the public setAttrs method, to set multiple attribute values."," *"," * @method _setAttrs"," * @protected"," * @param {Object} attrs An object with attributes name/value pairs."," * @param {Object} [opts] Optional data providing the circumstances for the change"," * @return {Object} A reference to the host object."," * @chainable"," */"," _setAttrs : function(attrs, opts) {"," var attr;"," for (attr in attrs) {"," if ( attrs.hasOwnProperty(attr) ) {"," this.set(attr, attrs[attr], opts);"," }"," }"," return this;"," },",""," /**"," * Gets multiple attribute values."," *"," * @method getAttrs"," * @param {Array | boolean} attrs Optional. An array of attribute names. If omitted, all attribute values are"," * returned. If set to true, all attributes modified from their initial values are returned."," * @return {Object} An object with attribute name/value pairs."," */"," getAttrs : function(attrs) {"," return this._getAttrs(attrs);"," },",""," /**"," * Implementation behind the public getAttrs method, to get multiple attribute values."," *"," * @method _getAttrs"," * @protected"," * @param {Array | boolean} attrs Optional. An array of attribute names. If omitted, all attribute values are"," * returned. If set to true, all attributes modified from their initial values are returned."," * @return {Object} An object with attribute name/value pairs."," */"," _getAttrs : function(attrs) {"," var obj = {},"," attr, i, len,"," modifiedOnly = (attrs === true);",""," // TODO - figure out how to get all \"added\""," if (!attrs || modifiedOnly) {"," attrs = O.keys(this._state.data);"," }",""," for (i = 0, len = attrs.length; i < len; i++) {"," attr = attrs[i];",""," if (!modifiedOnly || this._getStateVal(attr) != this._state.get(attr, INIT_VALUE)) {"," // Go through get, to honor cloning/normalization"," obj[attr] = this.get(attr);"," }"," }",""," return obj;"," },",""," /**"," * Configures a group of attributes, and sets initial values."," *"," * "," * NOTE: This method does not isolate the configuration object by merging/cloning."," * The caller is responsible for merging/cloning the configuration object if required."," *
"," *"," * @method addAttrs"," * @chainable"," *"," * @param {Object} cfgs An object with attribute name/configuration pairs."," * @param {Object} values An object with attribute name/value pairs, defining the initial values to apply."," * Values defined in the cfgs argument will be over-written by values in this argument unless defined as read only."," * @param {boolean} lazy Whether or not to delay the intialization of these attributes until the first call to get/set."," * Individual attributes can over-ride this behavior by defining a lazyAdd configuration property in their configuration."," * See addAttr."," *"," * @return {Object} A reference to the host object."," */"," addAttrs : function(cfgs, values, lazy) {"," var host = this; // help compression"," if (cfgs) {"," host._tCfgs = cfgs;"," host._tVals = host._normAttrVals(values);"," host._addAttrs(cfgs, host._tVals, lazy);"," host._tCfgs = host._tVals = null;"," }",""," return host;"," },",""," /**"," * Implementation behind the public addAttrs method."," *"," * This method is invoked directly by get if it encounters a scenario"," * in which an attribute's valueFn attempts to obtain the"," * value an attribute in the same group of attributes, which has not yet"," * been added (on demand initialization)."," *"," * @method _addAttrs"," * @private"," * @param {Object} cfgs An object with attribute name/configuration pairs."," * @param {Object} values An object with attribute name/value pairs, defining the initial values to apply."," * Values defined in the cfgs argument will be over-written by values in this argument unless defined as read only."," * @param {boolean} lazy Whether or not to delay the intialization of these attributes until the first call to get/set."," * Individual attributes can over-ride this behavior by defining a lazyAdd configuration property in their configuration."," * See addAttr."," */"," _addAttrs : function(cfgs, values, lazy) {"," var host = this, // help compression"," attr,"," attrCfg,"," value;",""," for (attr in cfgs) {"," if (cfgs.hasOwnProperty(attr)) {",""," // Not Merging. Caller is responsible for isolating configs"," attrCfg = cfgs[attr];"," attrCfg.defaultValue = attrCfg.value;",""," // Handle simple, complex and user values, accounting for read-only"," value = host._getAttrInitVal(attr, attrCfg, host._tVals);",""," if (value !== undefined) {"," attrCfg.value = value;"," }",""," if (host._tCfgs[attr]) {"," delete host._tCfgs[attr];"," }",""," host.addAttr(attr, attrCfg, lazy);"," }"," }"," },",""," /**"," * Utility method to protect an attribute configuration"," * hash, by merging the entire object and the individual"," * attr config objects."," *"," * @method _protectAttrs"," * @protected"," * @param {Object} attrs A hash of attribute to configuration object pairs."," * @return {Object} A protected version of the attrs argument."," * @deprecated Use `AttributeCore.protectAttrs()` or"," * `Attribute.protectAttrs()` which are the same static utility method."," */"," _protectAttrs : AttributeCore.protectAttrs,",""," /**"," * Utility method to normalize attribute values. The base implementation"," * simply merges the hash to protect the original."," *"," * @method _normAttrVals"," * @param {Object} valueHash An object with attribute name/value pairs"," *"," * @return {Object} An object literal with 2 properties - \"simple\" and \"complex\","," * containing simple and complex attribute values respectively keyed"," * by the top level attribute name, or null, if valueHash is falsey."," *"," * @private"," */"," _normAttrVals : function(valueHash) {"," var vals = {},"," subvals = {},"," path,"," attr,"," v, k;",""," if (valueHash) {"," for (k in valueHash) {"," if (valueHash.hasOwnProperty(k)) {"," if (k.indexOf(DOT) !== -1) {"," path = k.split(DOT);"," attr = path.shift();"," v = subvals[attr] = subvals[attr] || [];"," v[v.length] = {"," path : path,"," value: valueHash[k]"," };"," } else {"," vals[k] = valueHash[k];"," }"," }"," }"," return { simple:vals, complex:subvals };"," } else {"," return null;"," }"," },",""," /**"," * Returns the initial value of the given attribute from"," * either the default configuration provided, or the"," * over-ridden value if it exists in the set of initValues"," * provided and the attribute is not read-only."," *"," * @param {String} attr The name of the attribute"," * @param {Object} cfg The attribute configuration object"," * @param {Object} initValues The object with simple and complex attribute name/value pairs returned from _normAttrVals"," *"," * @return {Any} The initial value of the attribute."," *"," * @method _getAttrInitVal"," * @private"," */"," _getAttrInitVal : function(attr, cfg, initValues) {"," var val = cfg.value,"," valFn = cfg.valueFn,"," tmpVal,"," initValSet = false,"," simple,"," complex,"," i,"," l,"," path,"," subval,"," subvals;",""," if (!cfg.readOnly && initValues) {"," // Simple Attributes"," simple = initValues.simple;"," if (simple && simple.hasOwnProperty(attr)) {"," val = simple[attr];"," initValSet = true;"," }"," }",""," if (valFn && !initValSet) {"," if (!valFn.call) {"," valFn = this[valFn];"," }"," if (valFn) {"," tmpVal = valFn.call(this, attr);"," val = tmpVal;"," }"," }",""," if (!cfg.readOnly && initValues) {",""," // Complex Attributes (complex values applied, after simple, in case both are set)"," complex = initValues.complex;",""," if (complex && complex.hasOwnProperty(attr) && (val !== undefined) && (val !== null)) {"," subvals = complex[attr];"," for (i = 0, l = subvals.length; i < l; ++i) {"," path = subvals[i].path;"," subval = subvals[i].value;"," O.setValue(val, path, subval);"," }"," }"," }",""," return val;"," },",""," /**"," * Utility method to set up initial attributes defined during construction,"," * either through the constructor.ATTRS property, or explicitly passed in."," *"," * @method _initAttrs"," * @protected"," * @param attrs {Object} The attributes to add during construction (passed through to addAttrs)."," * These can also be defined on the constructor being augmented with Attribute by defining the ATTRS property on the constructor."," * @param values {Object} The initial attribute values to apply (passed through to addAttrs)."," * These are not merged/cloned. The caller is responsible for isolating user provided values if required."," * @param lazy {boolean} Whether or not to add attributes lazily (passed through to addAttrs)."," */"," _initAttrs : function(attrs, values, lazy) {"," // ATTRS support for Node, which is not Base based"," attrs = attrs || this.constructor.ATTRS;",""," var Base = Y.Base,"," BaseCore = Y.BaseCore,"," baseInst = (Base && Y.instanceOf(this, Base)),"," baseCoreInst = (!baseInst && BaseCore && Y.instanceOf(this, BaseCore));",""," if (attrs && !baseInst && !baseCoreInst) {"," this.addAttrs(Y.AttributeCore.protectAttrs(attrs), values, lazy);"," }"," }"," };",""," Y.AttributeCore = AttributeCore;","","","}, '@VERSION@', {\"requires\": [\"oop\"]});"]; +_yuitest_coverage["build/attribute-core/attribute-core.js"].lines = {"1":0,"14":0,"19":0,"22":0,"33":0,"35":0,"36":0,"39":0,"50":0,"53":0,"54":0,"57":0,"58":0,"59":0,"72":0,"74":0,"75":0,"87":0,"89":0,"90":0,"92":0,"93":0,"96":0,"97":0,"111":0,"113":0,"114":0,"132":0,"135":0,"136":0,"137":0,"138":0,"140":0,"141":0,"142":0,"147":0,"168":0,"225":0,"230":0,"232":0,"247":0,"248":0,"262":0,"273":0,"274":0,"275":0,"276":0,"277":0,"278":0,"283":0,"286":0,"301":0,"302":0,"406":0,"411":0,"413":0,"415":0,"416":0,"423":0,"425":0,"429":0,"431":0,"432":0,"435":0,"436":0,"438":0,"440":0,"442":0,"445":0,"449":0,"461":0,"477":0,"490":0,"501":0,"504":0,"505":0,"506":0,"523":0,"539":0,"560":0,"571":0,"572":0,"573":0,"574":0,"577":0,"578":0,"581":0,"583":0,"585":0,"587":0,"590":0,"591":0,"593":0,"595":0,"596":0,"599":0,"600":0,"604":0,"605":0,"608":0,"610":0,"611":0,"614":0,"615":0,"617":0,"618":0,"622":0,"623":0,"624":0,"625":0,"629":0,"634":0,"651":0,"659":0,"660":0,"661":0,"665":0,"666":0,"667":0,"668":0,"669":0,"673":0,"674":0,"677":0,"679":0,"681":0,"682":0,"685":0,"686":0,"688":0,"701":0,"702":0,"715":0,"716":0,"717":0,"719":0,"739":0,"750":0,"751":0,"753":0,"755":0,"756":0,"758":0,"759":0,"760":0,"765":0,"766":0,"767":0,"769":0,"771":0,"772":0,"774":0,"775":0,"776":0,"778":0,"780":0,"781":0,"786":0,"787":0,"788":0,"791":0,"792":0,"794":0,"799":0,"802":0,"815":0,"829":0,"830":0,"831":0,"832":0,"835":0,"847":0,"860":0,"865":0,"866":0,"869":0,"870":0,"872":0,"874":0,"878":0,"902":0,"903":0,"904":0,"905":0,"906":0,"907":0,"910":0,"931":0,"936":0,"937":0,"940":0,"941":0,"944":0,"946":0,"947":0,"950":0,"951":0,"954":0,"987":0,"993":0,"994":0,"995":0,"996":0,"997":0,"998":0,"999":0,"1000":0,"1005":0,"1009":0,"1011":0,"1031":0,"1043":0,"1045":0,"1046":0,"1047":0,"1048":0,"1052":0,"1053":0,"1054":0,"1056":0,"1057":0,"1058":0,"1062":0,"1065":0,"1067":0,"1068":0,"1069":0,"1070":0,"1071":0,"1072":0,"1077":0,"1094":0,"1096":0,"1101":0,"1102":0,"1107":0}; +_yuitest_coverage["build/attribute-core/attribute-core.js"].functions = {"State:14":0,"add:32":0,"addAll:49":0,"remove:71":0,"(anonymous 2):96":0,"removeAll:86":0,"get:110":0,"getAll:131":0,"AttributeCore:225":0,"protectAttrs:273":0,"_initAttrHost:300":0,"addAttr:403":0,"attrAdded:460":0,"get:476":0,"_isLazyAttr:489":0,"_addLazyAttr:500":0,"set:522":0,"_set:538":0,"_setAttr:559":0,"_getAttr:650":0,"_getStateVal:700":0,"_setStateVal:714":0,"_setAttrVal:737":0,"setAttrs:814":0,"_setAttrs:828":0,"getAttrs:846":0,"_getAttrs:859":0,"addAttrs:901":0,"_addAttrs:930":0,"_normAttrVals:986":0,"_getAttrInitVal:1030":0,"_initAttrs:1092":0,"(anonymous 1):1":0}; +_yuitest_coverage["build/attribute-core/attribute-core.js"].coveredLines = 236; _yuitest_coverage["build/attribute-core/attribute-core.js"].coveredFunctions = 33; _yuitest_coverline("build/attribute-core/attribute-core.js", 1); YUI.add('attribute-core', function (Y, NAME) { @@ -982,39 +982,45 @@ retVal = setter.call(host, newVal, name, opts); _yuitest_coverline("build/attribute-core/attribute-core.js", 774); if (retVal === INVALID_VALUE) { _yuitest_coverline("build/attribute-core/attribute-core.js", 775); +if (initializing) { + _yuitest_coverline("build/attribute-core/attribute-core.js", 776); +newVal = cfg.defaultValue; + } else { + _yuitest_coverline("build/attribute-core/attribute-core.js", 778); allowSet = false; - } else {_yuitest_coverline("build/attribute-core/attribute-core.js", 776); + } + } else {_yuitest_coverline("build/attribute-core/attribute-core.js", 780); if (retVal !== undefined){ - _yuitest_coverline("build/attribute-core/attribute-core.js", 777); + _yuitest_coverline("build/attribute-core/attribute-core.js", 781); newVal = retVal; }} } } - _yuitest_coverline("build/attribute-core/attribute-core.js", 782); + _yuitest_coverline("build/attribute-core/attribute-core.js", 786); if (allowSet) { - _yuitest_coverline("build/attribute-core/attribute-core.js", 783); + _yuitest_coverline("build/attribute-core/attribute-core.js", 787); if(!subAttrName && (newVal === prevRawVal) && !Lang.isObject(newVal)) { - _yuitest_coverline("build/attribute-core/attribute-core.js", 784); + _yuitest_coverline("build/attribute-core/attribute-core.js", 788); allowSet = false; } else { // Store value - _yuitest_coverline("build/attribute-core/attribute-core.js", 787); + _yuitest_coverline("build/attribute-core/attribute-core.js", 791); if (!(INIT_VALUE in cfg)) { - _yuitest_coverline("build/attribute-core/attribute-core.js", 788); + _yuitest_coverline("build/attribute-core/attribute-core.js", 792); cfg.initValue = newVal; } - _yuitest_coverline("build/attribute-core/attribute-core.js", 790); + _yuitest_coverline("build/attribute-core/attribute-core.js", 794); host._setStateVal(attrName, newVal); } } } else { - _yuitest_coverline("build/attribute-core/attribute-core.js", 795); + _yuitest_coverline("build/attribute-core/attribute-core.js", 799); allowSet = false; } - _yuitest_coverline("build/attribute-core/attribute-core.js", 798); + _yuitest_coverline("build/attribute-core/attribute-core.js", 802); return allowSet; }, @@ -1028,8 +1034,8 @@ return allowSet; * @chainable */ setAttrs : function(attrs, opts) { - _yuitest_coverfunc("build/attribute-core/attribute-core.js", "setAttrs", 810); -_yuitest_coverline("build/attribute-core/attribute-core.js", 811); + _yuitest_coverfunc("build/attribute-core/attribute-core.js", "setAttrs", 814); +_yuitest_coverline("build/attribute-core/attribute-core.js", 815); return this._setAttrs(attrs, opts); }, @@ -1044,18 +1050,18 @@ return this._setAttrs(attrs, opts); * @chainable */ _setAttrs : function(attrs, opts) { - _yuitest_coverfunc("build/attribute-core/attribute-core.js", "_setAttrs", 824); -_yuitest_coverline("build/attribute-core/attribute-core.js", 825); + _yuitest_coverfunc("build/attribute-core/attribute-core.js", "_setAttrs", 828); +_yuitest_coverline("build/attribute-core/attribute-core.js", 829); var attr; - _yuitest_coverline("build/attribute-core/attribute-core.js", 826); + _yuitest_coverline("build/attribute-core/attribute-core.js", 830); for (attr in attrs) { - _yuitest_coverline("build/attribute-core/attribute-core.js", 827); + _yuitest_coverline("build/attribute-core/attribute-core.js", 831); if ( attrs.hasOwnProperty(attr) ) { - _yuitest_coverline("build/attribute-core/attribute-core.js", 828); + _yuitest_coverline("build/attribute-core/attribute-core.js", 832); this.set(attr, attrs[attr], opts); } } - _yuitest_coverline("build/attribute-core/attribute-core.js", 831); + _yuitest_coverline("build/attribute-core/attribute-core.js", 835); return this; }, @@ -1068,8 +1074,8 @@ return this; * @return {Object} An object with attribute name/value pairs. */ getAttrs : function(attrs) { - _yuitest_coverfunc("build/attribute-core/attribute-core.js", "getAttrs", 842); -_yuitest_coverline("build/attribute-core/attribute-core.js", 843); + _yuitest_coverfunc("build/attribute-core/attribute-core.js", "getAttrs", 846); +_yuitest_coverline("build/attribute-core/attribute-core.js", 847); return this._getAttrs(attrs); }, @@ -1083,33 +1089,33 @@ return this._getAttrs(attrs); * @return {Object} An object with attribute name/value pairs. */ _getAttrs : function(attrs) { - _yuitest_coverfunc("build/attribute-core/attribute-core.js", "_getAttrs", 855); -_yuitest_coverline("build/attribute-core/attribute-core.js", 856); + _yuitest_coverfunc("build/attribute-core/attribute-core.js", "_getAttrs", 859); +_yuitest_coverline("build/attribute-core/attribute-core.js", 860); var obj = {}, attr, i, len, modifiedOnly = (attrs === true); // TODO - figure out how to get all "added" - _yuitest_coverline("build/attribute-core/attribute-core.js", 861); + _yuitest_coverline("build/attribute-core/attribute-core.js", 865); if (!attrs || modifiedOnly) { - _yuitest_coverline("build/attribute-core/attribute-core.js", 862); + _yuitest_coverline("build/attribute-core/attribute-core.js", 866); attrs = O.keys(this._state.data); } - _yuitest_coverline("build/attribute-core/attribute-core.js", 865); + _yuitest_coverline("build/attribute-core/attribute-core.js", 869); for (i = 0, len = attrs.length; i < len; i++) { - _yuitest_coverline("build/attribute-core/attribute-core.js", 866); + _yuitest_coverline("build/attribute-core/attribute-core.js", 870); attr = attrs[i]; - _yuitest_coverline("build/attribute-core/attribute-core.js", 868); + _yuitest_coverline("build/attribute-core/attribute-core.js", 872); if (!modifiedOnly || this._getStateVal(attr) != this._state.get(attr, INIT_VALUE)) { // Go through get, to honor cloning/normalization - _yuitest_coverline("build/attribute-core/attribute-core.js", 870); + _yuitest_coverline("build/attribute-core/attribute-core.js", 874); obj[attr] = this.get(attr); } } - _yuitest_coverline("build/attribute-core/attribute-core.js", 874); + _yuitest_coverline("build/attribute-core/attribute-core.js", 878); return obj; }, @@ -1134,22 +1140,22 @@ return obj; * @return {Object} A reference to the host object. */ addAttrs : function(cfgs, values, lazy) { - _yuitest_coverfunc("build/attribute-core/attribute-core.js", "addAttrs", 897); -_yuitest_coverline("build/attribute-core/attribute-core.js", 898); + _yuitest_coverfunc("build/attribute-core/attribute-core.js", "addAttrs", 901); +_yuitest_coverline("build/attribute-core/attribute-core.js", 902); var host = this; // help compression - _yuitest_coverline("build/attribute-core/attribute-core.js", 899); + _yuitest_coverline("build/attribute-core/attribute-core.js", 903); if (cfgs) { - _yuitest_coverline("build/attribute-core/attribute-core.js", 900); + _yuitest_coverline("build/attribute-core/attribute-core.js", 904); host._tCfgs = cfgs; - _yuitest_coverline("build/attribute-core/attribute-core.js", 901); + _yuitest_coverline("build/attribute-core/attribute-core.js", 905); host._tVals = host._normAttrVals(values); - _yuitest_coverline("build/attribute-core/attribute-core.js", 902); + _yuitest_coverline("build/attribute-core/attribute-core.js", 906); host._addAttrs(cfgs, host._tVals, lazy); - _yuitest_coverline("build/attribute-core/attribute-core.js", 903); + _yuitest_coverline("build/attribute-core/attribute-core.js", 907); host._tCfgs = host._tVals = null; } - _yuitest_coverline("build/attribute-core/attribute-core.js", 906); + _yuitest_coverline("build/attribute-core/attribute-core.js", 910); return host; }, @@ -1171,41 +1177,41 @@ return host; * See addAttr. */ _addAttrs : function(cfgs, values, lazy) { - _yuitest_coverfunc("build/attribute-core/attribute-core.js", "_addAttrs", 926); -_yuitest_coverline("build/attribute-core/attribute-core.js", 927); + _yuitest_coverfunc("build/attribute-core/attribute-core.js", "_addAttrs", 930); +_yuitest_coverline("build/attribute-core/attribute-core.js", 931); var host = this, // help compression attr, attrCfg, value; - _yuitest_coverline("build/attribute-core/attribute-core.js", 932); + _yuitest_coverline("build/attribute-core/attribute-core.js", 936); for (attr in cfgs) { - _yuitest_coverline("build/attribute-core/attribute-core.js", 933); + _yuitest_coverline("build/attribute-core/attribute-core.js", 937); if (cfgs.hasOwnProperty(attr)) { // Not Merging. Caller is responsible for isolating configs - _yuitest_coverline("build/attribute-core/attribute-core.js", 936); + _yuitest_coverline("build/attribute-core/attribute-core.js", 940); attrCfg = cfgs[attr]; - _yuitest_coverline("build/attribute-core/attribute-core.js", 937); + _yuitest_coverline("build/attribute-core/attribute-core.js", 941); attrCfg.defaultValue = attrCfg.value; // Handle simple, complex and user values, accounting for read-only - _yuitest_coverline("build/attribute-core/attribute-core.js", 940); + _yuitest_coverline("build/attribute-core/attribute-core.js", 944); value = host._getAttrInitVal(attr, attrCfg, host._tVals); - _yuitest_coverline("build/attribute-core/attribute-core.js", 942); + _yuitest_coverline("build/attribute-core/attribute-core.js", 946); if (value !== undefined) { - _yuitest_coverline("build/attribute-core/attribute-core.js", 943); + _yuitest_coverline("build/attribute-core/attribute-core.js", 947); attrCfg.value = value; } - _yuitest_coverline("build/attribute-core/attribute-core.js", 946); + _yuitest_coverline("build/attribute-core/attribute-core.js", 950); if (host._tCfgs[attr]) { - _yuitest_coverline("build/attribute-core/attribute-core.js", 947); + _yuitest_coverline("build/attribute-core/attribute-core.js", 951); delete host._tCfgs[attr]; } - _yuitest_coverline("build/attribute-core/attribute-core.js", 950); + _yuitest_coverline("build/attribute-core/attribute-core.js", 954); host.addAttr(attr, attrCfg, lazy); } } @@ -1239,43 +1245,43 @@ host.addAttr(attr, attrCfg, lazy); * @private */ _normAttrVals : function(valueHash) { - _yuitest_coverfunc("build/attribute-core/attribute-core.js", "_normAttrVals", 982); -_yuitest_coverline("build/attribute-core/attribute-core.js", 983); + _yuitest_coverfunc("build/attribute-core/attribute-core.js", "_normAttrVals", 986); +_yuitest_coverline("build/attribute-core/attribute-core.js", 987); var vals = {}, subvals = {}, path, attr, v, k; - _yuitest_coverline("build/attribute-core/attribute-core.js", 989); + _yuitest_coverline("build/attribute-core/attribute-core.js", 993); if (valueHash) { - _yuitest_coverline("build/attribute-core/attribute-core.js", 990); + _yuitest_coverline("build/attribute-core/attribute-core.js", 994); for (k in valueHash) { - _yuitest_coverline("build/attribute-core/attribute-core.js", 991); + _yuitest_coverline("build/attribute-core/attribute-core.js", 995); if (valueHash.hasOwnProperty(k)) { - _yuitest_coverline("build/attribute-core/attribute-core.js", 992); + _yuitest_coverline("build/attribute-core/attribute-core.js", 996); if (k.indexOf(DOT) !== -1) { - _yuitest_coverline("build/attribute-core/attribute-core.js", 993); + _yuitest_coverline("build/attribute-core/attribute-core.js", 997); path = k.split(DOT); - _yuitest_coverline("build/attribute-core/attribute-core.js", 994); + _yuitest_coverline("build/attribute-core/attribute-core.js", 998); attr = path.shift(); - _yuitest_coverline("build/attribute-core/attribute-core.js", 995); + _yuitest_coverline("build/attribute-core/attribute-core.js", 999); v = subvals[attr] = subvals[attr] || []; - _yuitest_coverline("build/attribute-core/attribute-core.js", 996); + _yuitest_coverline("build/attribute-core/attribute-core.js", 1000); v[v.length] = { path : path, value: valueHash[k] }; } else { - _yuitest_coverline("build/attribute-core/attribute-core.js", 1001); + _yuitest_coverline("build/attribute-core/attribute-core.js", 1005); vals[k] = valueHash[k]; } } } - _yuitest_coverline("build/attribute-core/attribute-core.js", 1005); + _yuitest_coverline("build/attribute-core/attribute-core.js", 1009); return { simple:vals, complex:subvals }; } else { - _yuitest_coverline("build/attribute-core/attribute-core.js", 1007); + _yuitest_coverline("build/attribute-core/attribute-core.js", 1011); return null; } }, @@ -1296,8 +1302,8 @@ return null; * @private */ _getAttrInitVal : function(attr, cfg, initValues) { - _yuitest_coverfunc("build/attribute-core/attribute-core.js", "_getAttrInitVal", 1026); -_yuitest_coverline("build/attribute-core/attribute-core.js", 1027); + _yuitest_coverfunc("build/attribute-core/attribute-core.js", "_getAttrInitVal", 1030); +_yuitest_coverline("build/attribute-core/attribute-core.js", 1031); var val = cfg.value, valFn = cfg.valueFn, tmpVal, @@ -1310,60 +1316,60 @@ var val = cfg.value, subval, subvals; - _yuitest_coverline("build/attribute-core/attribute-core.js", 1039); + _yuitest_coverline("build/attribute-core/attribute-core.js", 1043); if (!cfg.readOnly && initValues) { // Simple Attributes - _yuitest_coverline("build/attribute-core/attribute-core.js", 1041); + _yuitest_coverline("build/attribute-core/attribute-core.js", 1045); simple = initValues.simple; - _yuitest_coverline("build/attribute-core/attribute-core.js", 1042); + _yuitest_coverline("build/attribute-core/attribute-core.js", 1046); if (simple && simple.hasOwnProperty(attr)) { - _yuitest_coverline("build/attribute-core/attribute-core.js", 1043); + _yuitest_coverline("build/attribute-core/attribute-core.js", 1047); val = simple[attr]; - _yuitest_coverline("build/attribute-core/attribute-core.js", 1044); + _yuitest_coverline("build/attribute-core/attribute-core.js", 1048); initValSet = true; } } - _yuitest_coverline("build/attribute-core/attribute-core.js", 1048); + _yuitest_coverline("build/attribute-core/attribute-core.js", 1052); if (valFn && !initValSet) { - _yuitest_coverline("build/attribute-core/attribute-core.js", 1049); + _yuitest_coverline("build/attribute-core/attribute-core.js", 1053); if (!valFn.call) { - _yuitest_coverline("build/attribute-core/attribute-core.js", 1050); + _yuitest_coverline("build/attribute-core/attribute-core.js", 1054); valFn = this[valFn]; } - _yuitest_coverline("build/attribute-core/attribute-core.js", 1052); + _yuitest_coverline("build/attribute-core/attribute-core.js", 1056); if (valFn) { - _yuitest_coverline("build/attribute-core/attribute-core.js", 1053); + _yuitest_coverline("build/attribute-core/attribute-core.js", 1057); tmpVal = valFn.call(this, attr); - _yuitest_coverline("build/attribute-core/attribute-core.js", 1054); + _yuitest_coverline("build/attribute-core/attribute-core.js", 1058); val = tmpVal; } } - _yuitest_coverline("build/attribute-core/attribute-core.js", 1058); + _yuitest_coverline("build/attribute-core/attribute-core.js", 1062); if (!cfg.readOnly && initValues) { // Complex Attributes (complex values applied, after simple, in case both are set) - _yuitest_coverline("build/attribute-core/attribute-core.js", 1061); + _yuitest_coverline("build/attribute-core/attribute-core.js", 1065); complex = initValues.complex; - _yuitest_coverline("build/attribute-core/attribute-core.js", 1063); + _yuitest_coverline("build/attribute-core/attribute-core.js", 1067); if (complex && complex.hasOwnProperty(attr) && (val !== undefined) && (val !== null)) { - _yuitest_coverline("build/attribute-core/attribute-core.js", 1064); + _yuitest_coverline("build/attribute-core/attribute-core.js", 1068); subvals = complex[attr]; - _yuitest_coverline("build/attribute-core/attribute-core.js", 1065); + _yuitest_coverline("build/attribute-core/attribute-core.js", 1069); for (i = 0, l = subvals.length; i < l; ++i) { - _yuitest_coverline("build/attribute-core/attribute-core.js", 1066); + _yuitest_coverline("build/attribute-core/attribute-core.js", 1070); path = subvals[i].path; - _yuitest_coverline("build/attribute-core/attribute-core.js", 1067); + _yuitest_coverline("build/attribute-core/attribute-core.js", 1071); subval = subvals[i].value; - _yuitest_coverline("build/attribute-core/attribute-core.js", 1068); + _yuitest_coverline("build/attribute-core/attribute-core.js", 1072); O.setValue(val, path, subval); } } } - _yuitest_coverline("build/attribute-core/attribute-core.js", 1073); + _yuitest_coverline("build/attribute-core/attribute-core.js", 1077); return val; }, @@ -1381,25 +1387,25 @@ return val; */ _initAttrs : function(attrs, values, lazy) { // ATTRS support for Node, which is not Base based - _yuitest_coverfunc("build/attribute-core/attribute-core.js", "_initAttrs", 1088); -_yuitest_coverline("build/attribute-core/attribute-core.js", 1090); + _yuitest_coverfunc("build/attribute-core/attribute-core.js", "_initAttrs", 1092); +_yuitest_coverline("build/attribute-core/attribute-core.js", 1094); attrs = attrs || this.constructor.ATTRS; - _yuitest_coverline("build/attribute-core/attribute-core.js", 1092); + _yuitest_coverline("build/attribute-core/attribute-core.js", 1096); var Base = Y.Base, BaseCore = Y.BaseCore, baseInst = (Base && Y.instanceOf(this, Base)), baseCoreInst = (!baseInst && BaseCore && Y.instanceOf(this, BaseCore)); - _yuitest_coverline("build/attribute-core/attribute-core.js", 1097); + _yuitest_coverline("build/attribute-core/attribute-core.js", 1101); if (attrs && !baseInst && !baseCoreInst) { - _yuitest_coverline("build/attribute-core/attribute-core.js", 1098); + _yuitest_coverline("build/attribute-core/attribute-core.js", 1102); this.addAttrs(Y.AttributeCore.protectAttrs(attrs), values, lazy); } } }; - _yuitest_coverline("build/attribute-core/attribute-core.js", 1103); + _yuitest_coverline("build/attribute-core/attribute-core.js", 1107); Y.AttributeCore = AttributeCore; diff --git a/build/attribute-core/attribute-core-debug.js b/build/attribute-core/attribute-core-debug.js index 2b5290c55ba..473b0d5de65 100644 --- a/build/attribute-core/attribute-core-debug.js +++ b/build/attribute-core/attribute-core-debug.js @@ -779,8 +779,13 @@ YUI.add('attribute-core', function (Y, NAME) { retVal = setter.call(host, newVal, name, opts); if (retVal === INVALID_VALUE) { - Y.log('Attribute: ' + attrName + ', setter returned Attribute.INVALID_VALUE for value:' + newVal, 'warn', 'attribute'); - allowSet = false; + if (initializing) { + Y.log('Attribute: ' + attrName + ', setter returned Attribute.INVALID_VALUE for value:' + newVal + ', initializing to default value', 'warn', 'attribute'); + newVal = cfg.defaultValue; + } else { + Y.log('Attribute: ' + attrName + ', setter returned Attribute.INVALID_VALUE for value:' + newVal, 'warn', 'attribute'); + allowSet = false; + } } else if (retVal !== undefined){ Y.log('Attribute: ' + attrName + ', raw value: ' + newVal + ' modified by setter to:' + retVal, 'info', 'attribute'); newVal = retVal; diff --git a/build/attribute-core/attribute-core-min.js b/build/attribute-core/attribute-core-min.js index e3fecc96911..2d75571700b 100644 --- a/build/attribute-core/attribute-core-min.js +++ b/build/attribute-core/attribute-core-min.js @@ -1 +1 @@ -YUI.add("attribute-core",function(e,t){function E(e,t,n){this._yuievt=null,this._initAttrHost(e,t,n)}e.State=function(){this.data={}},e.State.prototype={add:function(e,t,n){var r=this.data[e];r||(r=this.data[e]={}),r[t]=n},addAll:function(e,t){var n=this.data[e],r;n||(n=this.data[e]={});for(r in t)t.hasOwnProperty(r)&&(n[r]=t[r])},remove:function(e,t){var n=this.data[e];n&&delete n[t]},removeAll:function(t,n){var r;n?e.each(n,function(e,n){this.remove(t,typeof n=="string"?n:e)},this):(r=this.data,t in r&&delete r[t])},get:function(e,t){var n=this.data[e];if(n)return n[t]},getAll:function(e,t){var n=this.data[e],r,i;if(t)i=n;else if(n){i={};for(r in n)n.hasOwnProperty(r)&&(i[r]=n[r])}return i}};var n=e.Object,r=e.Lang,i=".",s="getter",o="setter",u="readOnly",a="writeOnce",f="initOnly",l="validator",c="value",h="valueFn",p="lazyAdd",d="added",v="_bypassProxy",m="initializing",g="initValue",y="lazy",b="isLazyAdd",w;E.INVALID_VALUE={},w=E.INVALID_VALUE,E._ATTR_CFG=[o,s,l,c,h,a,u,p,v],E.protectAttrs=function(t){if(t){t=e.merge(t);for(var n in t)t.hasOwnProperty(n)&&(t[n]=e.merge(t[n]))}return t},E.prototype={_initAttrHost:function(t,n,r){this._state=new e.State,this._initAttrs(t,n,r)},addAttr:function(e,t,n){var r=this,i=r._state,s,o;t=t||{},n=p in t?t[p]:n;if(n&&!r.attrAdded(e))i.addAll(e,{lazy:t,added:!0});else if(!r.attrAdded(e)||i.get(e,b))o=c in t,o&&(s=t.value,delete t.value),t.added=!0,t.initializing=!0,i.addAll(e,t),o&&r.set(e,s),i.remove(e,m);return r},attrAdded:function(e){return!!this._state.get(e,d)},get:function(e){return this._getAttr(e)},_isLazyAttr:function(e){return this._state.get(e,y)},_addLazyAttr:function(e){var t=this._state,n=t.get(e,y);t.add(e,b,!0),t.remove(e,y),this.addAttr(e,n)},set:function(e,t,n){return this._setAttr(e,t,n)},_set:function(e,t,n){return this._setAttr(e,t,n,!0)},_setAttr:function(t,r,s,o){var u=!0,a=this._state,l=this._stateProxy,h,p,d,v,m,g,y;return t.indexOf(i)!==-1&&(d=t,v=t.split(i),t=v.shift()),this._isLazyAttr(t)&&this._addLazyAttr(t),h=a.getAll(t,!0)||{},p=!(c in h),l&&t in l&&!h._bypassProxy&&(p=!1),g=h.writeOnce,y=h.initializing,!p&&!o&&(g&&(u=!1),h.readOnly&&(u=!1)),!y&&!o&&g===f&&(u=!1),u&&(p||(m=this.get(t)),v&&(r=n.setValue(e.clone(m),v,r),r===undefined&&(u=!1)),u&&(s=s||{},!this._fireAttrChange||y?this._setAttrVal(t,d,m,r,s):this._fireAttrChange(t,d,m,r,s))),this},_getAttr:function(e){var t=this,r=e,o=t._state,u,a,f,l;return e.indexOf(i)!==-1&&(u=e.split(i),e=u.shift()),t._tCfgs&&t._tCfgs[e]&&(l={},l[e]=t._tCfgs[e],delete t._tCfgs[e],t._addAttrs(l,t._tVals)),t._isLazyAttr(e)&&t._addLazyAttr(e),f=t._getStateVal(e),a=o.get(e,s),a&&!a.call&&(a=this[a]),f=a?a.call(t,f,r):f,f=u?n.getValue(f,u):f,f},_getStateVal:function(e){var t=this._stateProxy;return t&&e in t&&!this._state.get(e,v)?t[e]:this._state.get(e,c)},_setStateVal:function(e,t){var n=this._stateProxy;n&&e in n&&!this._state.get(e,v)?n[e]=t:this._state.add(e,c,t)},_setAttrVal:function(e,t,n,i,s){var o=this,u=!0,a=this._state.getAll(e,!0)||{},f=a.validator,l=a.setter,c=a.initializing,h=this._getStateVal(e),p=t||e,d,v;return f&&(f.call||(f=this[f]),f&&(v=f.call(o,i,p,s),!v&&c&&(i=a.defaultValue,v=!0))),!f||v?(l&&(l.call||(l=this[l]),l&&(d=l.call(o,i,p,s),d===w?u=!1:d!==undefined&&(i=d))),u&&(!t&&i===h&&!r.isObject(i)?u=!1:(g in a||(a.initValue=i),o._setStateVal(e,i)))):u=!1,u},setAttrs:function(e,t){return this._setAttrs(e,t)},_setAttrs:function(e,t){var n;for(n in e)e.hasOwnProperty(n)&&this.set(n,e[n],t);return this},getAttrs:function(e){return this._getAttrs(e)},_getAttrs:function(e){var t={},r,i,s,o=e===!0;if(!e||o)e=n.keys(this._state.data);for(i=0,s=e.length;i