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

make highlight filter work with numeric query (fix #1400) #1402

Merged
merged 1 commit into from
Jan 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ var uis = angular.module('ui.select', [])
*/
.filter('highlight', function() {
function escapeRegexp(queryToEscape) {
return queryToEscape.replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1');
return ('' + queryToEscape).replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1');
}

return function(matchItem, query) {
Expand Down
7 changes: 7 additions & 0 deletions test/select.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2328,6 +2328,13 @@ describe('ui-select tests', function() {

expect(highlight(item, query)).toBe('20<span class="ui-select-highlight">15</span>');
});

it('properly works with numeric queries', function() {
var query = 15;
var item = 2015;

expect(highlight(item, query)).toBe('20<span class="ui-select-highlight">15</span>');
});
});

});