diff --git a/src/typeahead/test/typeahead-highlight.spec.js b/src/typeahead/test/typeahead-highlight.spec.js
index edfffea685..955ce6f0df 100644
--- a/src/typeahead/test/typeahead-highlight.spec.js
+++ b/src/typeahead/test/typeahead-highlight.spec.js
@@ -23,6 +23,12 @@ describe('typeaheadHighlight', function () {
expect(highlightFilter('before match after', 'nomatch')).toEqual('before match after');
});
+ it('should do nothing if no or empty query', function () {
+ expect(highlightFilter('before match after', '')).toEqual('before match after');
+ expect(highlightFilter('before match after', null)).toEqual('before match after');
+ expect(highlightFilter('before match after', undefined)).toEqual('before match after');
+ });
+
it('issue 316 - should work correctly for regexp reserved words', function () {
expect(highlightFilter('before (match after', '(match')).toEqual('before (match after');
});
diff --git a/src/typeahead/typeahead.js b/src/typeahead/typeahead.js
index f230862f75..c7f327b9ff 100644
--- a/src/typeahead/typeahead.js
+++ b/src/typeahead/typeahead.js
@@ -313,6 +313,6 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position'])
}
return function(matchItem, query) {
- return query ? matchItem.replace(new RegExp(escapeRegexp(query), 'gi'), '$&') : query;
+ return query ? matchItem.replace(new RegExp(escapeRegexp(query), 'gi'), '$&') : matchItem;
};
});
\ No newline at end of file