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

Commit

Permalink
fix(typeahead): correctly higlight numeric matches
Browse files Browse the repository at this point in the history
Fixes #1777
  • Loading branch information
pkozlowski-opensource committed Feb 10, 2014
1 parent cde6a45 commit 09678b1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/typeahead/test/typeahead-highlight.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <strong>(match</strong> after');
});

it('issue 1777 - should work correctly with numeric values', function () {
expect(highlightFilter(123, '2')).toEqual('1<strong>2</strong>3');
});
});
2 changes: 1 addition & 1 deletion src/typeahead/typeahead.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'), '<strong>$&</strong>') : matchItem;
return query ? ('' + matchItem).replace(new RegExp(escapeRegexp(query), 'gi'), '<strong>$&</strong>') : matchItem;
};
});

0 comments on commit 09678b1

Please sign in to comment.