2020-08-25 23:57:08 +00:00
|
|
|
'use strict';
|
|
|
|
|
2021-02-26 03:58:33 +00:00
|
|
|
var GetIntrinsic = require('../../GetIntrinsic');
|
|
|
|
|
|
|
|
var $defineProperty = GetIntrinsic('%Object.defineProperty%', true);
|
|
|
|
|
|
|
|
if ($defineProperty) {
|
|
|
|
try {
|
|
|
|
$defineProperty({}, 'a', { value: 1 });
|
|
|
|
} catch (e) {
|
|
|
|
// IE 8 has a broken defineProperty
|
|
|
|
$defineProperty = null;
|
|
|
|
}
|
2020-08-25 23:57:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = function defineProperty(O, P, Desc) {
|
2021-02-26 03:58:33 +00:00
|
|
|
if ($defineProperty) {
|
|
|
|
return $defineProperty(O, P, Desc);
|
2020-08-25 23:57:08 +00:00
|
|
|
}
|
|
|
|
if ((Desc.enumerable && Desc.configurable && Desc.writable) || !(P in O)) {
|
|
|
|
O[P] = Desc.value; // eslint-disable-line no-param-reassign
|
|
|
|
return O;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new SyntaxError('helper does not yet support this configuration');
|
|
|
|
};
|
2021-02-26 03:58:33 +00:00
|
|
|
module.exports.oDP = $defineProperty;
|