From 5ef8d1d31c2e90d452dcc01727b45d34bdb0bdcf Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Mon, 27 Jan 2014 17:35:27 -0800 Subject: [PATCH] fix(filterFilter): don't interpret dots in predicate object fields as paths Closes #6005 --- src/ng/filter/filter.js | 2 +- test/ng/filter/filterSpec.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ng/filter/filter.js b/src/ng/filter/filter.js index e328d61abe7d..b2773037479a 100644 --- a/src/ng/filter/filter.js +++ b/src/ng/filter/filter.js @@ -176,7 +176,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); } diff --git a/test/ng/filter/filterSpec.js b/test/ng/filter/filterSpec.js index cab24ec51aae..0bb487042ba3 100644 --- a/test/ng/filter/filterSpec.js +++ b/test/ng/filter/filterSpec.js @@ -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},