_object-dp.js 600 B

12345678910111213141516
  1. var anObject = require('./_an-object');
  2. var IE8_DOM_DEFINE = require('./_ie8-dom-define');
  3. var toPrimitive = require('./_to-primitive');
  4. var dP = Object.defineProperty;
  5. exports.f = require('./_descriptors') ? Object.defineProperty : function defineProperty(O, P, Attributes) {
  6. anObject(O);
  7. P = toPrimitive(P, true);
  8. anObject(Attributes);
  9. if (IE8_DOM_DEFINE) try {
  10. return dP(O, P, Attributes);
  11. } catch (e) { /* empty */ }
  12. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
  13. if ('value' in Attributes) O[P] = Attributes.value;
  14. return O;
  15. };