mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 17:07:49 +00:00
Extend baseCreateCallback to functions bound with native Function#bind and those with __bindData__ of false.
This commit is contained in:
30
lodash.js
30
lodash.js
@@ -1106,24 +1106,30 @@
|
||||
if (typeof func != 'function') {
|
||||
return identity;
|
||||
}
|
||||
// exit early if there is no `thisArg`
|
||||
if (typeof thisArg == 'undefined') {
|
||||
// exit early for no `thisArg` or already bound by `Function#bind`
|
||||
if (typeof thisArg == 'undefined' || !('prototype' in func)) {
|
||||
return func;
|
||||
}
|
||||
var bindData = func.__bindData__ || (support.funcNames && !func.name);
|
||||
var bindData = func.__bindData__;
|
||||
if (typeof bindData == 'undefined') {
|
||||
var source = reThis && fnToString.call(func);
|
||||
if (!support.funcNames && source && !reFuncName.test(source)) {
|
||||
bindData = true;
|
||||
if (support.funcNames) {
|
||||
bindData = !func.name;
|
||||
}
|
||||
if (support.funcNames || !bindData) {
|
||||
// checks if `func` references the `this` keyword and stores the result
|
||||
bindData = !support.funcDecomp || reThis.test(source);
|
||||
setBindData(func, bindData);
|
||||
bindData = bindData || !support.funcDecomp;
|
||||
if (!bindData) {
|
||||
var source = fnToString.call(func);
|
||||
if (!support.funcNames) {
|
||||
bindData = !reFuncName.test(source);
|
||||
}
|
||||
if (!bindData) {
|
||||
// checks if `func` references the `this` keyword and stores the result
|
||||
bindData = reThis.test(source);
|
||||
setBindData(func, bindData);
|
||||
}
|
||||
}
|
||||
}
|
||||
// exit early if there are no `this` references or `func` is bound
|
||||
if (bindData !== true && (bindData && bindData[1] & 1)) {
|
||||
if (bindData === false || (bindData !== true && bindData[1] & 1)) {
|
||||
return func;
|
||||
}
|
||||
switch (argCount) {
|
||||
@@ -1544,7 +1550,7 @@
|
||||
isPartialRight = partialRightArgs = false;
|
||||
}
|
||||
var bindData = func && func.__bindData__;
|
||||
if (bindData) {
|
||||
if (typeof bindData == 'object') {
|
||||
if (isBind && !(bindData[1] & 1)) {
|
||||
bindData[4] = thisArg;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user