Created
October 21, 2015 12:44
-
-
Save smolak/b4cd64a635925bae0b61 to your computer and use it in GitHub Desktop.
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
(function() { | |
var defineProperty = 'defineProperty' in Object, | |
defineGetter = '__defineGetter__' in Object; | |
// mini polyfill for defining getters | |
Object.extend({ | |
defineGetter: function(object, prop, fn) { | |
if (defineProperty) { | |
// console.log('defineProperty available'); | |
Object.defineProperty(object, prop, { | |
get: fn, | |
enumerable: false | |
}); | |
} | |
else if (defineGetter) { | |
// console.log('__defineGetter__ available'); | |
object.__defineGetter__(prop, fn); | |
} | |
else { | |
// fallback is a function for really old browsers. | |
object[prop] = fn; | |
} | |
} | |
}); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment