From 09678b1260dadb0a399d8e71fc2e1f5597c9ca31 Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Mon, 10 Feb 2014 22:05:37 +0100 Subject: [PATCH] fix(typeahead): correctly higlight numeric matches Fixes #1777 --- src/typeahead/test/typeahead-highlight.spec.js | 4 ++++ src/typeahead/typeahead.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/typeahead/test/typeahead-highlight.spec.js b/src/typeahead/test/typeahead-highlight.spec.js index 955ce6f0df..1a5aafc48d 100644 --- a/src/typeahead/test/typeahead-highlight.spec.js +++ b/src/typeahead/test/typeahead-highlight.spec.js @@ -32,4 +32,8 @@ describe('typeaheadHighlight', function () { it('issue 316 - should work correctly for regexp reserved words', function () { expect(highlightFilter('before (match after', '(match')).toEqual('before (match after'); }); + + it('issue 1777 - should work correctly with numeric values', function () { + expect(highlightFilter(123, '2')).toEqual('123'); + }); }); diff --git a/src/typeahead/typeahead.js b/src/typeahead/typeahead.js index 5dfecbcae7..8547c6f587 100644 --- a/src/typeahead/typeahead.js +++ b/src/typeahead/typeahead.js @@ -344,6 +344,6 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap } return function(matchItem, query) { - return query ? matchItem.replace(new RegExp(escapeRegexp(query), 'gi'), '$&') : matchItem; + return query ? ('' + matchItem).replace(new RegExp(escapeRegexp(query), 'gi'), '$&') : matchItem; }; }); \ No newline at end of file