2
0
mirror of https://github.com/devbridge/jQuery-Autocomplete.git synced 2024-11-29 00:06:36 +00:00

Update formatResult with only non Html replacement

Only non HTML replacement. That means replacement between <p>Your text</p> is ok, but <a href="your text" /> will not be replaced.
This commit is contained in:
xsyfrost 2014-11-20 11:39:59 +01:00
parent 05a337cba9
commit 534dbce469

View File

@ -126,9 +126,7 @@
$.Autocomplete = Autocomplete;
Autocomplete.formatResult = function (suggestion, currentValue) {
var pattern = '(' + utils.escapeRegExChars(currentValue) + ')';
return suggestion.value.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>');
return suggestion.value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + currentValue.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1") + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>");
};
Autocomplete.prototype = {