Skip to content

Commit

Permalink
minor fix of prototype methods export logic in the pure version
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Jan 18, 2024
1 parent 232c846 commit 82ab796
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions packages/core-js-pure/override/internals/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/core-js/internals/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 82ab796

Please sign in to comment.