mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 15:57:48 +00:00
Ensure _.reduce works with string Objects in IE < 9.
Former-commit-id: 0ee3496e52f4c393900f37f03e451b8e4abba206
This commit is contained in:
@@ -2152,7 +2152,7 @@
|
||||
'var noaccum = arguments.length < 3;\n' +
|
||||
'if (thisArg) callback = iteratorBind(callback, thisArg)',
|
||||
'beforeLoop': {
|
||||
'array': 'if (noaccum) result = collection[++index]'
|
||||
'array': 'if (noaccum) result = iteratee[++index]'
|
||||
},
|
||||
'inLoop': {
|
||||
'array':
|
||||
|
||||
24
test/test.js
24
test/test.js
@@ -1115,6 +1115,30 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.reduce');
|
||||
|
||||
(function() {
|
||||
_.each({
|
||||
'literal': 'abc',
|
||||
'object': Object('abc')
|
||||
},
|
||||
function(collection, key) {
|
||||
test('should work with a string ' + key + ' for `collection` (test in IE < 9)', function() {
|
||||
var args;
|
||||
|
||||
var actual = _.reduce(collection, function(accumulator, value) {
|
||||
args || (args = slice.call(arguments));
|
||||
return accumulator + value;
|
||||
});
|
||||
|
||||
deepEqual(args, ['a', 'b', 1, collection]);
|
||||
equal(actual, 'abc');
|
||||
});
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.reduceRight');
|
||||
|
||||
(function() {
|
||||
|
||||
Reference in New Issue
Block a user