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

@@ -1782,6 +1782,19 @@
deepEqual(_.toArray('abc'), ['a', 'b', 'c']);
deepEqual(_.toArray(Object('abc')), ['a', 'b', 'c']);
});
test('should work with a NodeList for `collection` (test in IE < 9)', function() {
if (window.document) {
try {
var nodeList = document.getElementsByTagName('body'),
body = nodeList[0],
actual = _.toArray(nodeList);
} catch(e) { }
deepEqual(actual, [body]);
} else {
skipTest();
}
});
}(1, 2, 3));
/*--------------------------------------------------------------------------*/