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

Commit b95d6c9

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 b95d6c9

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/ng/filter/filter.js

+4
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ function createPredicateFn(expression, comparator, matchAgainstAnyProp) {
151151
comparator = equals;
152152
} else if (!isFunction(comparator)) {
153153
comparator = function(actual, expected) {
154+
if (angular.isUndefined(expected)) {
155+
return true;
156+
}
157+
154158
if (isObject(actual) || isObject(expected)) {
155159
// Prevent an object to be considered equal to a string like `'[object'`
156160
return false;

test/ng/filter/filterSpec.js

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ describe('Filter: filter', function() {
4242
expect(filter(items, {}).length).toBe(2);
4343

4444
expect(filter(items, {name: 'a'}).length).toBe(2);
45+
expect(filter(items, {name: undefined}).length).toBe(2);
4546

4647
expect(filter(items, {name: 'b'}).length).toBe(1);
4748
expect(filter(items, {name: 'b'})[0].name).toBe('abc');

0 commit comments

Comments
 (0)