Created
October 14, 2011 00:44
-
-
Save dandean/1285942 to your computer and use it in GitHub Desktop.
How many holes can you poke in this? And do they really matter?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (!Object.defineProperty) { | |
| if (Object.__defineGetter__) { | |
| Object.defineProperty = function(obj, name, options) { | |
| if (!options) throw new Error("`options` is a required argument."); | |
| if ("get" in options || "set" in options) { | |
| if ("get" in options) { | |
| obj.__defineGetter__(name, options.get); | |
| } | |
| if ("set" in options) { | |
| obj.__defineSetter__(name, options.set); | |
| } | |
| } else if ("value" in options) { | |
| obj.__defineGetter__(name, options.value); | |
| obj.__defineSetter__(name, options.value); | |
| } | |
| }; | |
| Object.defineProperties = function(obj, properties) { | |
| for (var name in properties) { | |
| Object.defineProperty(obj, name, properties[name]); | |
| } | |
| }; | |
| } else throw new Error('Object.defineProperty cannot be used or shimmed in this environment.'); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment