mirror of
				https://github.com/flynx/colors.js.git
				synced 2025-10-31 12:00:08 +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
					
				| @ -50,11 +50,13 @@ var addProperty = function (color, func) { | |||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   if (Object.defineProperty) { |   if (Object.defineProperty) { | ||||||
|  |     if(!String.prototype.hasOwnProperty(color)) { | ||||||
|       Object.defineProperty(String.prototype, color, { |       Object.defineProperty(String.prototype, color, { | ||||||
|         get : func, |         get : func, | ||||||
|         configurable: true, |         configurable: true, | ||||||
|         enumerable: false |         enumerable: false | ||||||
|       }); |       }); | ||||||
|  |     } | ||||||
|   } else { |   } else { | ||||||
|     String.prototype.__defineGetter__(color, func); |     String.prototype.__defineGetter__(color, func); | ||||||
|   } |   } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user