/**
* Provides methods for managing custom Node data.
*
* @module node
* @main node
* @submodule node-data
*/
_initData: function() {
if (! ('_data' in this)) {
this._data = {};
}
},
/**
* @method getData
* @description Retrieves arbitrary data stored on a Node instance.
* If no data is associated with the Node, it will attempt to retrieve
* a value from the corresponding HTML data attribute. (e.g. node.getData('foo')
* will check node.getAttribute('data-foo')).
* @param {string} name Optional name of the data field to retrieve.
* If no name is given, all data is returned.
* @return {any | Object} Whatever is stored at the given field,
* or an object hash of all fields.
*/
this._initData();
} else { // initialize from HTML attribute
}
ret = {};
ret[n] = v;
});
}
return ret;
},
_getDataAttributes: function(ret) {
var i = 0,
prefix = this.DATA_PREFIX,
name;
while (i < len) {
}
}
i += 1;
}
return ret;
},
_getDataAttribute: function(name) {
return data;
},
/**
* @method setData
* @description Stores arbitrary data on a Node instance.
* This is not stored with the DOM node.
* @param {string} name The name of the field to set. If no name
* is given, name is treated as the data and overrides any existing data.
* @param {any} val The value to be assigned to the field.
* @chainable
*/
this._initData();
} else {
}
return this;
},
/**
* @method clearData
* @description Clears internally stored data.
* @param {string} name The name of the field to clear. If no name
* is given, all data is cleared.
* @chainable
*/
if ('_data' in this) {
if (typeof name != 'undefined') {
} else {
delete this._data;
}
}
return this;
}
});
/**
* @method getData
* @description Retrieves arbitrary data stored on each Node instance
* bound to the NodeList.
* @see Node
* @param {string} name Optional name of the data field to retrieve.
* If no name is given, all data is returned.
* @return {Array} An array containing all of the data for each Node instance.
* or an object hash of all fields.
*/
},
/**
* @method setData
* @description Stores arbitrary data on each Node instance bound to the
* NodeList. This is not stored with the DOM node.
* @param {string} name The name of the field to set. If no name
* is given, name is treated as the data and overrides any existing data.
* @param {any} val The value to be assigned to the field.
* @chainable
*/
},
/**
* @method clearData
* @description Clears data on all Node instances bound to the NodeList.
* @param {string} name The name of the field to clear. If no name
* is given, all data is cleared.
* @chainable
*/
}
});