Added defineProperty check/implementation. Is available (ie node.js) defineProperty is the correct way to add color properties so they aren't enumerable. Unintentional enumerable properties can cause global issues

This commit is contained in:
David Podolsky 2013-06-14 16:14:19 +00:00
parent 6ce311411e
commit 6045347a38

View File

@ -48,7 +48,16 @@ var addProperty = function (color, func) {
exports[color] = function (str) {
return func.apply(str);
};
String.prototype.__defineGetter__(color, func);
if (Object.defineProperty) {
Object.defineProperty(Object.prototype, color, {
get : func,
configurable: true,
enumerable: false
});
} else {
String.prototype.__defineGetter__(color, func);
}
};