summaryrefslogtreecommitdiff
path: root/src/node_modules/es-abstract/test/helpers/defineProperty.js
blob: 03102a8396923387247e5f20585bfcca2afffcd0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
'use strict';

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;
	}
}

module.exports = function defineProperty(O, P, Desc) {
	if ($defineProperty) {
		return $defineProperty(O, P, Desc);
	}
	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');
};
module.exports.oDP = $defineProperty;