diff --git a/CHANGELOG.md b/CHANGELOG.md index 5bd67c21de87..5165e16fd650 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - Fixed internal `ToLength` operation with bigints, [#1318](https://github.com/zloirock/core-js/issues/1318) - Removed significant redundant code from `String#split` polyfill - Fixed setting names of methods with symbol keys in some old engines +- Minor fix of prototype methods export logic in the pure version - Compat data improvements: - [`Iterator` helpers proposal](https://github.com/tc39/proposal-iterator-helpers) methods marked as supported from V8 ~ Chrome 122 - Note that V8 ~ Chrome 122 add [`Set` methods](https://github.com/tc39/proposal-set-methods), but they have [a bug](https://bugs.chromium.org/p/v8/issues/detail?id=14559) [similar to Safari](https://bugs.webkit.org/show_bug.cgi?id=267494) diff --git a/packages/core-js-pure/override/internals/export.js b/packages/core-js-pure/override/internals/export.js index 7630a0a4e9f4..854745c05b2b 100644 --- a/packages/core-js-pure/override/internals/export.js +++ b/packages/core-js-pure/override/internals/export.js @@ -45,7 +45,7 @@ module.exports = function (options, source) { var STATIC = options.stat; var PROTO = options.proto; - var nativeSource = GLOBAL ? global : STATIC ? global[TARGET] : (global[TARGET] || {}).prototype; + var nativeSource = GLOBAL ? global : STATIC ? global[TARGET] : global[TARGET] && global[TARGET].prototype; var target = GLOBAL ? path : path[TARGET] || createNonEnumerableProperty(path, TARGET, {})[TARGET]; var targetPrototype = target.prototype; @@ -68,7 +68,7 @@ module.exports = function (options, source) { // export native or implementation sourceProperty = (USE_NATIVE && nativeProperty) ? nativeProperty : source[key]; - if (USE_NATIVE && typeof targetProperty == typeof sourceProperty) continue; + if (!FORCED && !PROTO && typeof targetProperty == typeof sourceProperty) continue; // bind methods to global for calling from export context if (options.bind && USE_NATIVE) resultProperty = bind(sourceProperty, global); diff --git a/packages/core-js/internals/export.js b/packages/core-js/internals/export.js index 8dde266d4926..669f5ad0e69c 100644 --- a/packages/core-js/internals/export.js +++ b/packages/core-js/internals/export.js @@ -32,7 +32,7 @@ module.exports = function (options, source) { } else if (STATIC) { target = global[TARGET] || defineGlobalProperty(TARGET, {}); } else { - target = (global[TARGET] || {}).prototype; + target = global[TARGET] && global[TARGET].prototype; } if (target) for (key in source) { sourceProperty = source[key];