Skip to content

Commit

Permalink
add a workaround of a Nashorn bug with `Function.prototype.{ call, bi…
Browse files Browse the repository at this point in the history
…nd }`, close #1128
  • Loading branch information
zloirock committed Sep 27, 2022
1 parent 7af3ced commit 27b5630
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,5 +1,6 @@
## Changelog
##### Unreleased
- Added a workaround of a Nashorn bug with `Function.prototype.{ call, bind }`, [#1128](https://github.com/zloirock/core-js/issues/1128)
- `Array.prototype.{ group, groupToMap }` marked as [supported from V8 ~ Chromium 108](https://chromestatus.com/feature/5714791975878656)

##### [3.25.3 - 2022.09.26](https://github.com/zloirock/core-js/releases/tag/v3.25.3)
Expand Down
8 changes: 7 additions & 1 deletion packages/core-js/internals/function-uncurry-this.js
@@ -1,11 +1,17 @@
var fails = require('../internals/fails');
var NATIVE_BIND = require('../internals/function-bind-native');

var FunctionPrototype = Function.prototype;
var bind = FunctionPrototype.bind;
var call = FunctionPrototype.call;
var uncurryThis = NATIVE_BIND && bind.bind(call, call);

module.exports = NATIVE_BIND ? function (fn) {
var UNCURRY_WITH_NATIVE_BIND = NATIVE_BIND && !fails(function () {
// Nashorn bug, https://github.com/zloirock/core-js/issues/1128
return uncurryThis(''.slice)('12', 1) !== '2';
});

module.exports = UNCURRY_WITH_NATIVE_BIND ? function (fn) {
return fn && uncurryThis(fn);
} : function (fn) {
return fn && function () {
Expand Down

0 comments on commit 27b5630

Please sign in to comment.