Add support for NodeLists in _.toArray for IE < 9.

Former-commit-id: 67b26fe6fe60d77c0b38c48865bfd2ca56f7b470
This commit is contained in:
John-David Dalton
2012-11-19 20:47:16 -08:00
parent 7d5af3df05
commit 4a99c2e928
5 changed files with 76 additions and 54 deletions

View File

@@ -149,7 +149,7 @@
'template': ['escape'],
'throttle': [],
'times': [],
'toArray': ['values'],
'toArray': ['isString', 'values'],
'unescape': [],
'union': ['uniq'],
'uniq': ['identity', 'indexOf'],
@@ -1580,21 +1580,28 @@
.replace(/ *\(function\(\) *{[\s\S]+?}\(1\)\);\n/, '')
.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var (?:hasDontEnumBug|iteratesOwnLast|noArgsEnum).+\n/g, '');
// remove `iteratesOwnLast` from `isPlainObject`
source = source.replace(/(?:\s*\/\/.*)*\n( *)if *\(iteratesOwnLast[\s\S]+?\n\1}/, '');
// remove JScript [[DontEnum]] fix from `_.isEqual`
source = source.replace(/(?:\s*\/\/.*)*\n( *)if *\(hasDontEnumBug[\s\S]+?\n\1}/, '');
source = source.replace(matchFunction(source, 'isEqual'), function(match) {
return match.replace(/(?:\s*\/\/.*)*\n( *)if *\(hasDontEnumBug[\s\S]+?\n\1}/, '');
});
// remove `noArraySliceOnStrings` from `_.toArray`
source = source.replace(/noArraySliceOnStrings *\?[^:]+: *([^)]+)/g, '$1');
// remove `iteratesOwnLast` from `isPlainObject`
source = source.replace(matchFunction(source, 'isPlainObject'), function(match) {
return match.replace(/(?:\s*\/\/.*)*\n( *)if *\(iteratesOwnLast[\s\S]+?\n\1}/, '');
});
// remove `noCharByIndex` from `_.reduceRight`
source = source.replace(/}\s*else if *\(noCharByIndex[^}]+/, '');
source = source.replace(matchFunction(source, 'reduceRight'), function(match) {
return match.replace(/}\s*else if *\(noCharByIndex[^}]+/, '');
});
// remove `noCharByIndex` from `_.toArray`
source = source.replace(matchFunction(source, 'toArray'), function(match) {
return match.replace(/(?:\s*\/\/.*)*\n( *)if *\(noCharByIndex[\s\S]+?\n\1}/, '');
});
source = removeVar(source, 'extendIteratorOptions');
source = removeVar(source, 'iteratorTemplate');
source = removeVar(source, 'noArraySliceOnStrings');
source = removeVar(source, 'noCharByIndex');
source = removeNoArgsClass(source);
source = removeNoNodeClass(source);
@@ -1730,9 +1737,6 @@
// remove `templateSettings` assignment
source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *lodash\.templateSettings[\s\S]+?};\n/, '');
}
if (isRemoved(source, 'toArray')) {
source = removeVar(source, 'noArraySliceOnStrings');
}
if (isRemoved(source, 'clone', 'isArguments', 'isEmpty', 'isEqual')) {
source = removeNoArgsClass(source);
}