Description: drop __proto__ calls Author: Yadd Forwarded: no Last-Update: 2022-11-30 --- a/object/set-prototype-of/shim.js +++ b/object/set-prototype-of/shim.js @@ -30,7 +30,7 @@ }; } else { fn = function (obj, prototype) { - validate(obj, prototype).__proto__ = prototype; + Object.setPrototypeOf(validate(obj, prototype), prototype); return obj; }; } @@ -39,9 +39,9 @@ var isNullBase; validate(obj, prototype); isNullBase = objIsPrototypeOf.call(self.nullPolyfill, obj); - if (isNullBase) delete self.nullPolyfill.__proto__; + if (isNullBase) Object.setPrototypeOf(self.nullPolyfill, null); if (prototype === null) prototype = self.nullPolyfill; - obj.__proto__ = prototype; + Object.setPrototypeOf(obj, prototype); if (isNullBase) defineProperty(self.nullPolyfill, "__proto__", nullDesc); return obj; }; @@ -67,11 +67,11 @@ if (Object.getPrototypeOf(tmpObj1) === tmpObj2) return { set: set, level: 2 }; } - tmpObj1.__proto__ = tmpObj2; + Object.setPrototypeOf(tmpObj1, tmpObj2); if (Object.getPrototypeOf(tmpObj1) === tmpObj2) return { level: 2 }; tmpObj1 = {}; - tmpObj1.__proto__ = tmpObj2; + Object.setPrototypeOf(tmpObj1, tmpObj2); if (Object.getPrototypeOf(tmpObj1) === tmpObj2) return { level: 1 }; return false; --- a/test/array/from/shim.js +++ b/test/array/from/shim.js @@ -44,7 +44,9 @@ a.deep(t({ length: 1, 0: "a" }), ["a"], "Null context"); - a(t({ __proto__: { 0: "abc", length: 1 } })[0], "abc", "Values on prototype"); + const tmpObj = new Object(); + Object.setPrototypeOf(tmpObj, { 0: "abc", length: 1 }); + a(t(tmpObj)[0], "abc", "Values on prototype"); a.throws( function () {