mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 07:17:50 +00:00
Ensure commit and reverse track __chain__` settings. [closes #958]
This commit is contained in:
@@ -5570,7 +5570,7 @@
|
||||
* // => [1, 2, 3]
|
||||
*/
|
||||
function wrapperCommit() {
|
||||
return new LodashWrapper(this.value());
|
||||
return new LodashWrapper(this.value(), this.__chain__);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5638,7 +5638,7 @@
|
||||
if (this.__actions__.length) {
|
||||
value = new LazyWrapper(this);
|
||||
}
|
||||
return new LodashWrapper(value.reverse());
|
||||
return new LodashWrapper(value.reverse(), this.__chain__);
|
||||
}
|
||||
return this.thru(function(value) {
|
||||
return value.reverse();
|
||||
|
||||
22
test/test.js
22
test/test.js
@@ -14570,6 +14570,17 @@
|
||||
skipTest(4);
|
||||
}
|
||||
});
|
||||
|
||||
test('should track the `__chain__` value of a wrapper', 2, function() {
|
||||
if (!isNpm) {
|
||||
var wrapper = _([1]).chain().commit().first();
|
||||
ok(wrapper instanceof _);
|
||||
strictEqual(wrapper.value(), 1);
|
||||
}
|
||||
else {
|
||||
skipTest(2);
|
||||
}
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
@@ -14745,6 +14756,17 @@
|
||||
skipTest(4);
|
||||
}
|
||||
});
|
||||
|
||||
test('should track the `__chain__` value of a wrapper', 2, function() {
|
||||
if (!isNpm) {
|
||||
var wrapper = _([1, 2, 3]).chain().reverse().first();
|
||||
ok(wrapper instanceof _);
|
||||
strictEqual(wrapper.value(), 3);
|
||||
}
|
||||
else {
|
||||
skipTest(2);
|
||||
}
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user