1 /* eslint-disable no-proto -- safe */
2 var uncurryThis = require('../internals/function-uncurry-this');
3 var anObject = require('../internals/an-object');
4 var aPossiblePrototype = require('../internals/a-possible-prototype');
6 // `Object.setPrototypeOf` method
7 // https://tc39.es/ecma262/#sec-object.setprototypeof
8 // Works with __proto__ only. Old v8 can't work with null proto objects.
9 // eslint-disable-next-line es/no-object-setprototypeof -- safe
10 module.exports = Object.setPrototypeOf || ('__proto__' in {} ? function () {
11 var CORRECT_SETTER = false;
15 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
16 setter = uncurryThis(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set);
18 CORRECT_SETTER = test instanceof Array;
19 } catch (error) { /* empty */ }
20 return function setPrototypeOf(O, proto) {
22 aPossiblePrototype(proto);
23 if (CORRECT_SETTER) setter(O, proto);
24 else O.__proto__ = proto;