mirror of
https://github.com/devbridge/jQuery-Autocomplete.git
synced 2024-11-25 14:17:45 +00:00
Fix issue of highlighting string when it contains html specific characters, fixes #385
This commit is contained in:
parent
9d06ec6f19
commit
3328147b93
@ -127,15 +127,15 @@
|
|||||||
$.Autocomplete = Autocomplete;
|
$.Autocomplete = Autocomplete;
|
||||||
|
|
||||||
Autocomplete.formatResult = function (suggestion, currentValue) {
|
Autocomplete.formatResult = function (suggestion, currentValue) {
|
||||||
var htmlSafeString = suggestion.value
|
var pattern = '(' + utils.escapeRegExChars(currentValue) + ')';
|
||||||
|
|
||||||
|
return suggestion.value
|
||||||
|
.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>')
|
||||||
.replace(/&/g, '&')
|
.replace(/&/g, '&')
|
||||||
.replace(/</g, '<')
|
.replace(/</g, '<')
|
||||||
.replace(/>/g, '>')
|
.replace(/>/g, '>')
|
||||||
.replace(/"/g, '"');
|
.replace(/"/g, '"')
|
||||||
|
.replace(/<(\/?strong)>/g, '<$1>');
|
||||||
var pattern = '(' + utils.escapeRegExChars(currentValue) + ')';
|
|
||||||
|
|
||||||
return htmlSafeString.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Autocomplete.prototype = {
|
Autocomplete.prototype = {
|
||||||
|
Loading…
Reference in New Issue
Block a user