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

Commit

Permalink
fix(filterFilter): don't interpret dots in predicate object fields as…
Browse files Browse the repository at this point in the history
… paths

Closes #6005
Closes #6009
  • Loading branch information
IgorMinar committed Jan 31, 2014
1 parent 29432ff commit 339a165
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ng/filter/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ function filterFilter() {
(function(path) {
if (typeof expression[path] == 'undefined') return;
predicates.push(function(value) {
return search(path == '$' ? value : getter(value, path), expression[path]);
return search(path == '$' ? value : (value && value[path]), expression[path]);
});
})(key);
}
Expand Down
10 changes: 10 additions & 0 deletions test/ng/filter/filterSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ describe('Filter: filter', function() {
expect(filter(items, {first:'misko', last:'hevery'})[0]).toEqual(items[0]);
});


it('should support predicat object with dots in the name', function() {
var items = [{'first.name': 'misko', 'last.name': 'hevery'},
{'first.name': 'adam', 'last.name': 'abrons'}];

expect(filter(items, {'first.name':'', 'last.name':''}).length).toBe(2);
expect(filter(items, {'first.name':'misko', 'last.name':''})).toEqual([items[0]]);
});


it('should match any properties for given "$" property', function() {
var items = [{first: 'tom', last: 'hevery'},
{first: 'adam', last: 'hevery', alias: 'tom', done: false},
Expand Down

0 comments on commit 339a165

Please sign in to comment.