mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-16 18:51:06 +00:00
fix(filterFilter): don't interpret dots in predicate object fields as paths
Closes #6005 Closes #6009
This commit is contained in:
parent
29432ffe37
commit
339a1658cd
2 changed files with 11 additions and 1 deletions
|
|
@ -188,7 +188,7 @@ function filterFilter() {
|
||||||
(function(path) {
|
(function(path) {
|
||||||
if (typeof expression[path] == 'undefined') return;
|
if (typeof expression[path] == 'undefined') return;
|
||||||
predicates.push(function(value) {
|
predicates.push(function(value) {
|
||||||
return search(path == '$' ? value : getter(value, path), expression[path]);
|
return search(path == '$' ? value : (value && value[path]), expression[path]);
|
||||||
});
|
});
|
||||||
})(key);
|
})(key);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,16 @@ describe('Filter: filter', function() {
|
||||||
expect(filter(items, {first:'misko', last:'hevery'})[0]).toEqual(items[0]);
|
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() {
|
it('should match any properties for given "$" property', function() {
|
||||||
var items = [{first: 'tom', last: 'hevery'},
|
var items = [{first: 'tom', last: 'hevery'},
|
||||||
{first: 'adam', last: 'hevery', alias: 'tom', done: false},
|
{first: 'adam', last: 'hevery', alias: 'tom', done: false},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue