Debian Codegraph @

debian/patches/drop-__proto__-calls.patch

raw
1 Description: drop __proto__ calls
2 Author: Yadd <[email protected]>
3 Forwarded: no
4 Last-Update: 2022-10-25
5
6 --- a/es6-sham.js
7 +++ b/es6-sham.js
8 @@ -111,7 +111,7 @@
9 } else {
10 // verify if null objects are buggy
11 /* eslint-disable no-proto */
12 - set.__proto__ = objProto;
13 + Object.setPrototypeOf(set, objProto);
14 /* eslint-enable no-proto */
15 // if null objects are buggy
16 // nodejs 0.8 to 0.10
17 @@ -119,7 +119,7 @@
18 setPrototypeOf = function (origin, proto) {
19 // use such bug to promote
20 /* eslint-disable no-proto */
21 - origin.__proto__ = proto;
22 + Object.setPrototypeOf(origin, proto);
23 /* eslint-enable no-proto */
24 return origin;
25 };
26 @@ -131,7 +131,7 @@
27 if (getPrototypeOf(origin)) {
28 // use __proto__ to promote
29 /* eslint-disable no-proto */
30 - origin.__proto__ = proto;
31 + Object.setPrototypeOf(origin, proto);
32 /* eslint-enable no-proto */
33 return origin;
34 }
35 --- a/es6-shim.js
36 +++ b/es6-shim.js
37 @@ -1558,7 +1558,18 @@
38 set = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set;
39 _call(set, {}, null);
40 } catch (e) {
41 - if (Object.prototype !== ({}).__proto__) { // eslint-disable-line no-proto
42 + // On modern engines that disallow __proto__ access (e.g. node
43 + // --disable-proto=throw), defer to the native Object.setPrototypeOf
44 + // when available rather than building a polyfill that would itself
45 + // throw.
46 + if (typeof Object.setPrototypeOf === 'function') {
47 + return Object.setPrototypeOf;
48 + }
49 + const protoAccess = Object.getPrototypeOf;
50 + if (protoAccess) {
51 + if (Object.prototype !== Object.getPrototypeOf({})) return;
52 + }
53 + else if (Object.prototype !== ({}).__proto__) { // eslint-disable-line no-proto
54 // IE < 11 cannot be shimmed
55 return;
56 }
57 --- a/test/array.js
58 +++ b/test/array.js
59 @@ -12,7 +12,7 @@
60 var ifSymbolUnscopablesIt = isSymbol(Sym.unscopables) ? it : it.skip;
61 var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it;
62 var ifSupportsDescriptorsIt = Object.getOwnPropertyDescriptor ? it : it.skip;
63 - var ifHasDunderProtoIt = [].__proto__ === Array.prototype ? it : it.skip; // eslint-disable-line no-proto
64 + var ifHasDunderProtoIt = Object.getPrototypeOf([]) === Array.prototype ? it : it.skip; // eslint-disable-line no-proto
65
66 var isNegativeZero = function (x) {
67 return (1 / x) < 0;