Make _.where iterate over only own properties.

Former-commit-id: 29b4cafe5271cad70c711c2d401cea627fa97e33
This commit is contained in:
John-David Dalton
2012-11-11 20:00:20 -08:00
parent ed66ff88a1
commit f6d28a90e3
4 changed files with 37 additions and 15 deletions

View File

@@ -1855,14 +1855,13 @@
deepEqual(_.where(array, { 'a': 1, 'b': 2 }), [{ 'a': 1, 'b': 2 }]);
});
test('should filter by inherited properties', function() {
test('should not filter by inherited properties', function() {
function Foo() {}
Foo.prototype = { 'b': 2 };
Foo.prototype = { 'a': 2 };
var properties = new Foo;
properties.a = 1;
deepEqual(_.where(array, properties), [{ 'a': 1, 'b': 2 }]);
properties.b = 2;
deepEqual(_.where(array, properties), [{ 'a': 1, 'b': 2 }, { 'a': 2, 'b': 2 }]);
});
test('should filter by problem JScript properties (test in IE < 9)', function() {