Skip to content

Commit 5ef8d1d

Browse files
committed
fix(filterFilter): don't interpret dots in predicate object fields as paths
Closes angular#6005
1 parent 8a0be35 commit 5ef8d1d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/ng/filter/filter.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ function filterFilter() {
176176
(function(path) {
177177
if (typeof expression[path] == 'undefined') return;
178178
predicates.push(function(value) {
179-
return search(path == '$' ? value : getter(value, path), expression[path]);
179+
return search(path == '$' ? value : (value && value[path]), expression[path]);
180180
});
181181
})(key);
182182
}

test/ng/filter/filterSpec.js

+10
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ describe('Filter: filter', function() {
6060
expect(filter(items, {first:'misko', last:'hevery'})[0]).toEqual(items[0]);
6161
});
6262

63+
64+
it('should support predicat object with dots in the name', function() {
65+
var items = [{'first.name': 'misko', 'last.name': 'hevery'},
66+
{'first.name': 'adam', 'last.name': 'abrons'}];
67+
68+
expect(filter(items, {'first.name':'', 'last.name':''}).length).toBe(2);
69+
expect(filter(items, {'first.name':'misko', 'last.name':''})).toEqual([items[0]]);
70+
});
71+
72+
6373
it('should match any properties for given "$" property', function() {
6474
var items = [{first: 'tom', last: 'hevery'},
6575
{first: 'adam', last: 'hevery', alias: 'tom', done: false},

0 commit comments

Comments
 (0)