mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 02:47:50 +00:00
Fixes #397
This commit is contained in:
@@ -955,8 +955,11 @@
|
|||||||
each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
|
each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
|
||||||
var method = ArrayProto[name];
|
var method = ArrayProto[name];
|
||||||
wrapper.prototype[name] = function() {
|
wrapper.prototype[name] = function() {
|
||||||
method.apply(this._wrapped, arguments);
|
var wrapped = this._wrapped;
|
||||||
return result(this._wrapped, this._chain);
|
method.apply(wrapped, arguments);
|
||||||
|
var length = wrapped.length;
|
||||||
|
if ((name == 'shift' || name == 'splice') && length === 0) delete wrapped[0];
|
||||||
|
return result(wrapped, this._chain);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user