|
1071 | 1071 | // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test
|
1072 | 1072 | if (!IS_NODE$1 && typeof PromiseRejectionEvent != 'function') return true;
|
1073 | 1073 | }
|
| 1074 | + // We need Promise#finally in the pure version for preventing prototype pollution |
| 1075 | + if (isPure && !PromiseConstructor.prototype['finally']) return true; |
1074 | 1076 | // We can't use @@species feature detection in V8 since it causes
|
1075 | 1077 | // deoptimization and performance degradation
|
1076 | 1078 | // https://github.com/zloirock/core-js/issues/679
|
|
1290 | 1292 | : newGenericPromiseCapability(C);
|
1291 | 1293 | };
|
1292 | 1294 |
|
1293 |
| - if (typeof nativePromiseConstructor == 'function') { |
| 1295 | + if (!isPure && typeof nativePromiseConstructor == 'function') { |
1294 | 1296 | nativeThen = nativePromiseConstructor.prototype.then;
|
1295 | 1297 |
|
1296 | 1298 | // wrap native Promise#then for native async functions
|
|
1332 | 1334 | }
|
1333 | 1335 | });
|
1334 | 1336 |
|
1335 |
| - _export({ target: PROMISE, stat: true, forced: FORCED }, { |
| 1337 | + _export({ target: PROMISE, stat: true, forced: isPure || FORCED }, { |
1336 | 1338 | // `Promise.resolve` method
|
1337 | 1339 | // https://tc39.github.io/ecma262/#sec-promise.resolve
|
1338 | 1340 | resolve: function resolve(x) {
|
1339 |
| - return promiseResolve(this, x); |
| 1341 | + return promiseResolve(isPure && this === PromiseWrapper ? PromiseConstructor : this, x); |
1340 | 1342 | }
|
1341 | 1343 | });
|
1342 | 1344 |
|
|
1797 | 1799 | return getInternalState$1(this).description;
|
1798 | 1800 | }
|
1799 | 1801 | });
|
1800 |
| - if (!isPure) { |
| 1802 | + { |
1801 | 1803 | redefine(ObjectPrototype, 'propertyIsEnumerable', $propertyIsEnumerable, { unsafe: true });
|
1802 | 1804 | }
|
1803 | 1805 | }
|
|
2160 | 2162 | if (anyNativeIterator) {
|
2161 | 2163 | CurrentIteratorPrototype = objectGetPrototypeOf(anyNativeIterator.call(new Iterable()));
|
2162 | 2164 | if (IteratorPrototype$2 !== Object.prototype && CurrentIteratorPrototype.next) {
|
2163 |
| - if (!isPure && objectGetPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype$2) { |
| 2165 | + if (objectGetPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype$2) { |
2164 | 2166 | if (objectSetPrototypeOf) {
|
2165 | 2167 | objectSetPrototypeOf(CurrentIteratorPrototype, IteratorPrototype$2);
|
2166 | 2168 | } else if (typeof CurrentIteratorPrototype[ITERATOR$4] != 'function') {
|
|
2169 | 2171 | }
|
2170 | 2172 | // Set @@toStringTag to native iterators
|
2171 | 2173 | setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true);
|
2172 |
| - if (isPure) iterators[TO_STRING_TAG] = returnThis$2; |
2173 | 2174 | }
|
2174 | 2175 | }
|
2175 | 2176 |
|
|
2180 | 2181 | }
|
2181 | 2182 |
|
2182 | 2183 | // define iterator
|
2183 |
| - if ((!isPure || FORCED) && IterablePrototype[ITERATOR$4] !== defaultIterator) { |
| 2184 | + if (IterablePrototype[ITERATOR$4] !== defaultIterator) { |
2184 | 2185 | createNonEnumerableProperty(IterablePrototype, ITERATOR$4, defaultIterator);
|
2185 | 2186 | }
|
2186 | 2187 | iterators[NAME] = defaultIterator;
|
|
0 commit comments