axe-core
Version:
Accessibility engine for automated Web UI testing
51 lines (48 loc) • 1.2 kB
JavaScript
/* global color */
/**
* API for handling incomplete color data
* @namespace axe.commons.color.incompleteData
* @inner
*/
color.incompleteData = (function() {
var data = {};
return {
/**
* Store incomplete data by key with a string value
* @method set
* @memberof axe.commons.color.incompleteData
* @instance
* @param {String} key Identifier for missing data point (fgColor, bgColor, etc.)
* @param {String} reason Missing data reason to match message template
*/
set: function(key, reason) {
if (typeof key !== 'string') {
throw new Error('Incomplete data: key must be a string');
}
if (reason) {
data[key] = reason;
}
return data[key];
},
/**
* Get incomplete data by key
* @method get
* @memberof axe.commons.color.incompleteData
* @instance
* @param {String} key Identifier for missing data point (fgColor, bgColor, etc.)
* @return {String} String for reason we couldn't tell
*/
get: function(key) {
return data[key];
},
/**
* Clear incomplete data on demand
* @method clear
* @memberof axe.commons.color.incompleteData
* @instance
*/
clear: function() {
data = {};
}
};
})();