Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit df5f775

Browse files
author
Casey Howard
committed
fix(filterFilter): Fix filtering using an object expression when the filter value is undefined
Fixes #10419
1 parent aac3c4a commit df5f775

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/ng/filter/filter.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ function deepCompare(actual, expected, comparator, matchAgainstAnyProp) {
196196
} else if (expectedType === 'object') {
197197
for (key in expected) {
198198
var expectedVal = expected[key];
199-
if (isFunction(expectedVal)) {
199+
if (isFunction(expectedVal) || isUndefined(expectedVal)) {
200200
continue;
201201
}
202202

test/ng/filter/filterSpec.js

+9
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ describe('Filter: filter', function() {
4848
});
4949

5050

51+
it('should filter when a specific property is undefined', function() {
52+
var items = [{name: 'a'}, {name: 'abc'}];
53+
expect(filter(items, {name: undefined})).toEqual([{name: 'a'}, {name: 'abc'}]);
54+
55+
items = [{first: 'misko'}, {deep: {first: 'misko'}}, {deep: {last: 'hevery'}}];
56+
expect(filter(items, {deep: {first: undefined}})).toEqual([{deep: {first: 'misko'}}, {deep: {last: 'hevery'}}]);
57+
});
58+
59+
5160
it('should take function as predicate', function() {
5261
var items = [{name: 'a'}, {name: 'abc', done: true}];
5362
expect(filter(items, function(i) {return i.done;}).length).toBe(1);

0 commit comments

Comments
 (0)