22 lines
847 B
JavaScript
22 lines
847 B
JavaScript
var DESCRIPTORS = require('../internals/descriptors');
|
|
var IE8_DOM_DEFINE = require('../internals/ie8-dom-define');
|
|
var anObject = require('../internals/an-object');
|
|
var toPrimitive = require('../internals/to-primitive');
|
|
|
|
// eslint-disable-next-line es/no-object-defineproperty -- safe
|
|
var $defineProperty = Object.defineProperty;
|
|
|
|
// `Object.defineProperty` method
|
|
// https://tc39.es/ecma262/#sec-object.defineproperty
|
|
exports.f = DESCRIPTORS ? $defineProperty : function defineProperty(O, P, Attributes) {
|
|
anObject(O);
|
|
P = toPrimitive(P, true);
|
|
anObject(Attributes);
|
|
if (IE8_DOM_DEFINE) try {
|
|
return $defineProperty(O, P, Attributes);
|
|
} catch (error) { /* empty */ }
|
|
if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
|
|
if ('value' in Attributes) O[P] = Attributes.value;
|
|
return O;
|
|
};
|