mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-02 16:17:50 +00:00
Fix deferred chaining test fails.
This commit is contained in:
41
lodash.js
41
lodash.js
@@ -9641,25 +9641,19 @@
|
||||
};
|
||||
});
|
||||
|
||||
// add `Array` functions that return the existing wrapped value
|
||||
arrayEach(['push', 'reverse', 'sort', 'unshift'], function(methodName) {
|
||||
var func = arrayProto[methodName];
|
||||
// add `Array` functions that return wrapped value
|
||||
arrayEach(['concat', 'push', 'reverse', 'sort', 'splice', 'unshift'], function(methodName) {
|
||||
var func = arrayProto[methodName],
|
||||
retVal = methodName == 'concat' || methodName == 'splice';
|
||||
|
||||
lodash.prototype[methodName] = function() {
|
||||
var args = arguments;
|
||||
return this.tap(function(value) {
|
||||
func.apply(value, args);
|
||||
return this[retVal ? 'thru' : 'tap'](function(value) {
|
||||
return func.apply(value, args);
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
// add `Array` functions that return new wrapped values
|
||||
arrayEach(['concat', 'splice'], function(methodName) {
|
||||
var func = arrayProto[methodName];
|
||||
lodash.prototype[methodName] = function() {
|
||||
return new lodashWrapper(func.apply(this.value(), arguments), this.__chain__);
|
||||
};
|
||||
});
|
||||
|
||||
// avoid array-like object bugs with `Array#shift` and `Array#splice`
|
||||
// in IE < 9, Firefox < 10, Narwhal, and RingoJS
|
||||
if (!support.spliceObjects) {
|
||||
@@ -9667,14 +9661,23 @@
|
||||
var func = arrayProto[methodName],
|
||||
isSplice = methodName == 'splice';
|
||||
|
||||
function process(value, args) {
|
||||
var result = func.apply(value, args);
|
||||
if (value.length === 0) {
|
||||
delete value[0];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
lodash.prototype[methodName] = function() {
|
||||
var args = arguments;
|
||||
var args = arguments,
|
||||
chainAll = this.__chain__;
|
||||
|
||||
if (!chainAll && !isSplice) {
|
||||
return process(this.value(), args);
|
||||
}
|
||||
return this[isSplice ? 'thru' : 'tap'](function(value) {
|
||||
var result = func.apply(value, args);
|
||||
if (value.length === 0) {
|
||||
delete value[0];
|
||||
}
|
||||
return result;
|
||||
return process(value, args);
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
@@ -11823,7 +11823,7 @@
|
||||
if (!isNpm) {
|
||||
var wrapped = _({ '0': 1, 'length': 1 });
|
||||
if (methodName == 'splice') {
|
||||
wrapped.splice(0, 1);
|
||||
wrapped.splice(0, 1).value();
|
||||
} else {
|
||||
wrapped[methodName]();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user