Skip to content

Commit 339a165

Browse files
committed
fix(filterFilter): don't interpret dots in predicate object fields as paths
Closes angular#6005 Closes angular#6009
1 parent 29432ff commit 339a165

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
@@ -188,7 +188,7 @@ function filterFilter() {
188188
(function(path) {
189189
if (typeof expression[path] == 'undefined') return;
190190
predicates.push(function(value) {
191-
return search(path == '$' ? value : getter(value, path), expression[path]);
191+
return search(path == '$' ? value : (value && value[path]), expression[path]);
192192
});
193193
})(key);
194194
}

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)