From 27b563077e152ca1ef5d09e8f798e0077d6c1991 Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Wed, 28 Sep 2022 01:49:21 +0700 Subject: [PATCH] add a workaround of a Nashorn bug with `Function.prototype.{ call, bind }`, close #1128 --- CHANGELOG.md | 1 + packages/core-js/internals/function-uncurry-this.js | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03c60251a55f..86bdabf54ec2 100644 --- a/CHANGELOG.md +++ b/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) diff --git a/packages/core-js/internals/function-uncurry-this.js b/packages/core-js/internals/function-uncurry-this.js index 4e6de173264f..4add61f64311 100644 --- a/packages/core-js/internals/function-uncurry-this.js +++ b/packages/core-js/internals/function-uncurry-this.js @@ -1,3 +1,4 @@ +var fails = require('../internals/fails'); var NATIVE_BIND = require('../internals/function-bind-native'); var FunctionPrototype = Function.prototype; @@ -5,7 +6,12 @@ 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 () {