mirror of
https://github.com/flynx/colors.js.git
synced 2025-10-29 11:00:11 +00:00
Prevent the defineProperty being called when property already exists
This commit is contained in:
parent
fd82d005d7
commit
3f6fe70f39
12
colors.js
12
colors.js
@ -50,11 +50,13 @@ var addProperty = function (color, func) {
|
||||
};
|
||||
|
||||
if (Object.defineProperty) {
|
||||
Object.defineProperty(String.prototype, color, {
|
||||
get : func,
|
||||
configurable: true,
|
||||
enumerable: false
|
||||
});
|
||||
if(!String.prototype.hasOwnProperty(color)) {
|
||||
Object.defineProperty(String.prototype, color, {
|
||||
get : func,
|
||||
configurable: true,
|
||||
enumerable: false
|
||||
});
|
||||
}
|
||||
} else {
|
||||
String.prototype.__defineGetter__(color, func);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user