Add support in _.isEmpty and _.size for jQuery/MooTools DOM query collections.

Former-commit-id: dc834256d09d7a3f2797ba65690961aad00717bf
This commit is contained in:
John-David Dalton
2012-08-12 21:40:46 -07:00
parent 2aa2ea9675
commit 361c91e610
3 changed files with 40 additions and 12 deletions

View File

@@ -713,6 +713,13 @@
equal(_.isEmpty({ 'length': 0 }), false);
});
test('should work with array-like collections', function() {
function Foo(elements) { Array.prototype.push.apply(this, elements); }
Foo.prototype = { 'splice': Array.prototype.splice };
equal(_.isEmpty(new Foo([])), true);
});
test('should work with `arguments` objects (test in IE < 9)', function() {
equal(_.isEmpty(args), false);
});
@@ -1084,6 +1091,13 @@
equal(_.size({ 'length': 3 }), 1);
});
test('should work with array-like collections', function() {
function Foo(elements) { Array.prototype.push.apply(this, elements); }
Foo.prototype = { 'splice': Array.prototype.splice };
equal(_.size(new Foo([1, 2, 3])), 3);
});
test('should work with `arguments` objects (test in IE < 9)', function() {
equal(_.size(args), 3);
});