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
					
				
							
								
								
									
										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