Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix uncurryThis on Nashorn #1129

Merged
merged 2 commits into from
Sep 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions packages/core-js/internals/function-uncurry-this.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
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);

var UNCURRY_WITH_NATIVE_BIND = NATIVE_BIND && !fails(function () {
module.exports = function (fn) {
// 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 () {
return fn && (NATIVE_BIND && fn instanceof Function ? uncurryThis(fn) : function () {
return call.apply(fn, arguments);
};
});
};