1 | var anObject = require('../internals/an-object');
|
2 | var aPossiblePrototype = require('../internals/a-possible-prototype');
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | module.exports = Object.setPrototypeOf || ('__proto__' in {} ? function () {
|
9 | var CORRECT_SETTER = false;
|
10 | var test = {};
|
11 | var setter;
|
12 | try {
|
13 | setter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set;
|
14 | setter.call(test, []);
|
15 | CORRECT_SETTER = test instanceof Array;
|
16 | } catch (error) { }
|
17 | return function setPrototypeOf(O, proto) {
|
18 | anObject(O);
|
19 | aPossiblePrototype(proto);
|
20 | if (CORRECT_SETTER) setter.call(O, proto);
|
21 | else O.__proto__ = proto;
|
22 | return O;
|
23 | };
|
24 | }() : undefined);
|