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