Skip to content

Commit

Permalink
Fix Object.setPrototypeOf
Browse files Browse the repository at this point in the history
  • Loading branch information
stonechoe committed Feb 22, 2024
1 parent 9fcf79b commit 805f352
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/core-js/internals/object-set-prototype-of.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
'use strict';
/* eslint-disable no-proto -- safe */
var uncurryThisAccessor = require('../internals/function-uncurry-this-accessor');
var anObject = require('../internals/an-object');
var isObject = require('../internals/is-object');
var requireObjectCoercible = require('../internals/require-object-coercible');
var aPossiblePrototype = require('../internals/a-possible-prototype');

// `Object.setPrototypeOf` method
Expand All @@ -18,8 +19,9 @@ module.exports = Object.setPrototypeOf || ('__proto__' in {} ? function () {
CORRECT_SETTER = test instanceof Array;
} catch (error) { /* empty */ }
return function setPrototypeOf(O, proto) {
anObject(O);
requireObjectCoercible(O);
aPossiblePrototype(proto);
if (!isObject(O)) return O;
if (CORRECT_SETTER) setter(O, proto);
else O.__proto__ = proto;
return O;
Expand Down

0 comments on commit 805f352

Please sign in to comment.