Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 09678b1

Browse files
fix(typeahead): correctly higlight numeric matches
Fixes #1777
1 parent cde6a45 commit 09678b1

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/typeahead/test/typeahead-highlight.spec.js

+4
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,8 @@ describe('typeaheadHighlight', function () {
3232
it('issue 316 - should work correctly for regexp reserved words', function () {
3333
expect(highlightFilter('before (match after', '(match')).toEqual('before <strong>(match</strong> after');
3434
});
35+
36+
it('issue 1777 - should work correctly with numeric values', function () {
37+
expect(highlightFilter(123, '2')).toEqual('1<strong>2</strong>3');
38+
});
3539
});

src/typeahead/typeahead.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,6 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap
344344
}
345345

346346
return function(matchItem, query) {
347-
return query ? matchItem.replace(new RegExp(escapeRegexp(query), 'gi'), '<strong>$&</strong>') : matchItem;
347+
return query ? ('' + matchItem).replace(new RegExp(escapeRegexp(query), 'gi'), '<strong>$&</strong>') : matchItem;
348348
};
349349
});

0 commit comments

Comments
 (0)