polyfill-service
Version:
A polyfill combinator
1 lines • 6.09 kB
JSON
{"aliases":["es5","modernizr:es5object","default","blissfuljs"],"browsers":{"firefox":"3.6","safari":"4 - 4.1","ios_saf":"4.3","firefox_mob":"3.6","ie":"6 - 8"},"dependencies":["Function.prototype.bind"],"docs":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty","baseDir":"Object/getOwnPropertyDescriptor","hasTests":true,"rawSource":"\n// Object.getOwnPropertyDescriptor\n(function() {\n\tvar call = Function.prototype.call;\n\tvar prototypeOfObject = Object.prototype;\n\tvar owns = call.bind(prototypeOfObject.hasOwnProperty);\n\n\tvar defineGetter;\n\tvar defineSetter;\n\tvar lookupGetter;\n\tvar lookupSetter;\n\tvar supportsAccessors;\n\tif ((supportsAccessors = owns(prototypeOfObject, \"__defineGetter__\"))) {\n\t defineGetter = call.bind(prototypeOfObject.__defineGetter__);\n\t defineSetter = call.bind(prototypeOfObject.__defineSetter__);\n\t lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);\n\t lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);\n\t}\n\tfunction doesGetOwnPropertyDescriptorWork(object) {\n\t try {\n\t object.sentinel = 0;\n\t return Object.getOwnPropertyDescriptor(\n\t object,\n\t \"sentinel\"\n\t ).value === 0;\n\t } catch (exception) {\n\t // returns falsy\n\t }\n\t}\n\t// check whether getOwnPropertyDescriptor works if it's given. Otherwise,\n\t// shim partially.\n\tif (Object.defineProperty) {\n\t var getOwnPropertyDescriptorWorksOnObject =\n\t doesGetOwnPropertyDescriptorWork({});\n\t var getOwnPropertyDescriptorWorksOnDom = typeof document == \"undefined\" ||\n\t doesGetOwnPropertyDescriptorWork(document.createElement(\"div\"));\n\t if (!getOwnPropertyDescriptorWorksOnDom ||\n\t !getOwnPropertyDescriptorWorksOnObject\n\t ) {\n\t var getOwnPropertyDescriptorFallback = Object.getOwnPropertyDescriptor;\n\t }\n\t}\n\n\tif (!Object.getOwnPropertyDescriptor || getOwnPropertyDescriptorFallback) {\n\t var ERR_NON_OBJECT = \"Object.getOwnPropertyDescriptor called on a non-object: \";\n\n\t Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {\n\t if ((typeof object != \"object\" && typeof object != \"function\") || object === null) {\n\t throw new TypeError(ERR_NON_OBJECT + object);\n\t }\n\n\t // make a valiant attempt to use the real getOwnPropertyDescriptor\n\t // for I8's DOM elements.\n\t if (getOwnPropertyDescriptorFallback) {\n\t try {\n\t return getOwnPropertyDescriptorFallback.call(Object, object, property);\n\t } catch (exception) {\n\t // try the shim if the real one doesn't work\n\t }\n\t }\n\n\t // If object does not owns property return undefined immediately.\n\t if (!owns(object, property)) {\n\t return;\n\t }\n\n\t // If object has a property then it's for sure both `enumerable` and\n\t // `configurable`.\n\t var descriptor = { enumerable: true, configurable: true };\n\n\t // If JS engine supports accessor properties then property may be a\n\t // getter or setter.\n\t if (supportsAccessors) {\n\t // Unfortunately `__lookupGetter__` will return a getter even\n\t // if object has own non getter property along with a same named\n\t // inherited getter. To avoid misbehavior we temporary remove\n\t // `__proto__` so that `__lookupGetter__` will return getter only\n\t // if it's owned by an object.\n\t var prototype = object.__proto__;\n\t object.__proto__ = prototypeOfObject;\n\n\t var getter = lookupGetter(object, property);\n\t var setter = lookupSetter(object, property);\n\n\t // Once we have getter and setter we can put values back.\n\t object.__proto__ = prototype;\n\n\t if (getter || setter) {\n\t if (getter) {\n\t descriptor.get = getter;\n\t }\n\t if (setter) {\n\t descriptor.set = setter;\n\t }\n\t // If it was accessor property we're done and return here\n\t // in order to avoid adding `value` to the descriptor.\n\t return descriptor;\n\t }\n\t }\n\n\t // If we got this far we know that object has an own property that is\n\t // not an accessor so we set it as a value and return descriptor.\n\t descriptor.value = object[property];\n\t return descriptor;\n\t };\n\t}\n}())","minSource":"!function(){function e(e){try{return e.sentinel=0,0===Object.getOwnPropertyDescriptor(e,\"sentinel\").value}catch(t){}}var t,r,n,o,i,_=Function.prototype.call,c=Object.prototype,p=_.bind(c.hasOwnProperty);if((i=p(c,\"__defineGetter__\"))&&(t=_.bind(c.__defineGetter__),r=_.bind(c.__defineSetter__),n=_.bind(c.__lookupGetter__),o=_.bind(c.__lookupSetter__)),Object.defineProperty){var f=e({}),a=\"undefined\"==typeof document||e(document.createElement(\"div\"));if(!a||!f)var u=Object.getOwnPropertyDescriptor}if(!Object.getOwnPropertyDescriptor||u){var b=\"Object.getOwnPropertyDescriptor called on a non-object: \";Object.getOwnPropertyDescriptor=function(e,t){if(\"object\"!=typeof e&&\"function\"!=typeof e||null===e)throw new TypeError(b+e);if(u)try{return u.call(Object,e,t)}catch(r){}if(p(e,t)){var _={enumerable:!0,configurable:!0};if(i){var f=e.__proto__;e.__proto__=c;var a=n(e,t),l=o(e,t);if(e.__proto__=f,a||l)return a&&(_.get=a),l&&(_.set=l),_}return _.value=e[t],_}}}}();","detectSource":"'getOwnPropertyDescriptor' in Object && typeof Object.getOwnPropertyDescriptor === 'function' && (function() {\n try {\n \tvar object = {};\n object.test = 0;\n return Object.getOwnPropertyDescriptor(\n object,\n \"test\"\n ).value === 0;\n } catch (exception) {\n return false\n }\n}())"}