mirror of
https://github.com/flynx/colors.js.git
synced 2025-10-29 19:10:10 +00:00
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:
parent
6ce311411e
commit
6045347a38
11
colors.js
11
colors.js
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user