2016-10-10 03:43:44 +02:00
|
|
|
// 26.1.13 Reflect.set(target, propertyKey, V [, receiver])
|
2017-08-14 05:01:11 +02:00
|
|
|
var dP = require('./_object-dp');
|
|
|
|
var gOPD = require('./_object-gopd');
|
|
|
|
var getPrototypeOf = require('./_object-gpo');
|
|
|
|
var has = require('./_has');
|
|
|
|
var $export = require('./_export');
|
|
|
|
var createDesc = require('./_property-desc');
|
|
|
|
var anObject = require('./_an-object');
|
|
|
|
var isObject = require('./_is-object');
|
2016-10-10 03:43:44 +02:00
|
|
|
|
2017-08-14 05:01:11 +02:00
|
|
|
function set(target, propertyKey, V /* , receiver */) {
|
|
|
|
var receiver = arguments.length < 4 ? target : arguments[3];
|
|
|
|
var ownDesc = gOPD.f(anObject(target), propertyKey);
|
|
|
|
var existingDescriptor, proto;
|
|
|
|
if (!ownDesc) {
|
|
|
|
if (isObject(proto = getPrototypeOf(target))) {
|
2016-10-10 03:43:44 +02:00
|
|
|
return set(proto, propertyKey, V, receiver);
|
|
|
|
}
|
|
|
|
ownDesc = createDesc(0);
|
|
|
|
}
|
2017-08-14 05:01:11 +02:00
|
|
|
if (has(ownDesc, 'value')) {
|
|
|
|
if (ownDesc.writable === false || !isObject(receiver)) return false;
|
2017-05-27 17:36:13 +02:00
|
|
|
existingDescriptor = gOPD.f(receiver, propertyKey) || createDesc(0);
|
2016-10-10 03:43:44 +02:00
|
|
|
existingDescriptor.value = V;
|
2017-05-27 17:36:13 +02:00
|
|
|
dP.f(receiver, propertyKey, existingDescriptor);
|
2016-10-10 03:43:44 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return ownDesc.set === undefined ? false : (ownDesc.set.call(receiver, V), true);
|
|
|
|
}
|
|
|
|
|
2017-08-14 05:01:11 +02:00
|
|
|
$export($export.S, 'Reflect', { set: set });
|