core-js-pure
Advanced tools
Comparing version 3.11.2 to 3.11.3
@@ -7,5 +7,5 @@ var IS_PURE = require('../internals/is-pure'); | ||
})('versions', []).push({ | ||
version: '3.11.2', | ||
version: '3.11.3', | ||
mode: IS_PURE ? 'pure' : 'global', | ||
copyright: '© 2021 Denis Pushkarev (zloirock.ru)' | ||
}); |
@@ -33,5 +33,8 @@ 'use strict'; | ||
// patch native Promise.prototype for native async functions | ||
if (!IS_PURE && typeof NativePromise == 'function' && !NativePromise.prototype['finally']) { | ||
redefine(NativePromise.prototype, 'finally', getBuiltIn('Promise').prototype['finally']); | ||
// makes sure that native promise-based APIs `Promise#finally` properly works with patched `Promise#then` | ||
if (!IS_PURE && typeof NativePromise == 'function') { | ||
var method = getBuiltIn('Promise').prototype['finally']; | ||
if (NativePromise.prototype['finally'] !== method) { | ||
redefine(NativePromise.prototype, 'finally', method, { unsafe: true }); | ||
} | ||
} |
@@ -39,2 +39,3 @@ 'use strict'; | ||
var PromiseConstructor = NativePromise; | ||
var PromiseConstructorPrototype = NativePromisePrototype; | ||
var TypeError = global.TypeError; | ||
@@ -64,3 +65,3 @@ var document = global.document; | ||
// We need Promise#finally in the pure version for preventing prototype pollution | ||
if (IS_PURE && !PromiseConstructor.prototype['finally']) return true; | ||
if (IS_PURE && !PromiseConstructorPrototype['finally']) return true; | ||
// We can't use @@species feature detection in V8 since it causes | ||
@@ -244,2 +245,3 @@ // deoptimization and performance degradation | ||
}; | ||
PromiseConstructorPrototype = PromiseConstructor.prototype; | ||
// eslint-disable-next-line no-unused-vars -- required for `.length` | ||
@@ -258,3 +260,3 @@ Internal = function Promise(executor) { | ||
}; | ||
Internal.prototype = redefineAll(PromiseConstructor.prototype, { | ||
Internal.prototype = redefineAll(PromiseConstructorPrototype, { | ||
// `Promise.prototype.then` method | ||
@@ -295,11 +297,16 @@ // https://tc39.es/ecma262/#sec-promise.prototype.then | ||
// make `Promise#then` return a polyfilled `Promise` for native promise-based APIs | ||
if (!SUBCLASSING) redefine(NativePromisePrototype, 'then', function then(onFulfilled, onRejected) { | ||
var that = this; | ||
return new PromiseConstructor(function (resolve, reject) { | ||
nativeThen.call(that, resolve, reject); | ||
}).then(onFulfilled, onRejected); | ||
// https://github.com/zloirock/core-js/issues/640 | ||
}, { unsafe: true }); | ||
if (!SUBCLASSING) { | ||
// make `Promise#then` return a polyfilled `Promise` for native promise-based APIs | ||
redefine(NativePromisePrototype, 'then', function then(onFulfilled, onRejected) { | ||
var that = this; | ||
return new PromiseConstructor(function (resolve, reject) { | ||
nativeThen.call(that, resolve, reject); | ||
}).then(onFulfilled, onRejected); | ||
// https://github.com/zloirock/core-js/issues/640 | ||
}, { unsafe: true }); | ||
// makes sure that native promise-based APIs `Promise#catch` properly works with patched `Promise#then` | ||
redefine(NativePromisePrototype, 'catch', PromiseConstructorPrototype['catch'], { unsafe: true }); | ||
} | ||
// make `.constructor === Promise` work for native promise-based APIs | ||
@@ -312,3 +319,3 @@ try { | ||
if (setPrototypeOf) { | ||
setPrototypeOf(NativePromisePrototype, PromiseConstructor.prototype); | ||
setPrototypeOf(NativePromisePrototype, PromiseConstructorPrototype); | ||
} | ||
@@ -315,0 +322,0 @@ } |
{ | ||
"name": "core-js-pure", | ||
"description": "Standard library", | ||
"version": "3.11.2", | ||
"version": "3.11.3", | ||
"repository": { | ||
@@ -58,3 +58,3 @@ "type": "git", | ||
}, | ||
"gitHead": "040f7836ad467dae5a0b849b02442a3ed2607b18" | ||
"gitHead": "bfe345ad3db933bdf1d5fd934c57959f83d30a91" | ||
} |
625498
15119