Side navigation
#4325 closed bug (invalid)
Opened March 10, 2009 06:19PM UTC
Closed October 12, 2009 11:59PM UTC
[autocomplete] highlight function inserts "</strong>" for every character if variable term is empty string
Reported by: | selfsimilar | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 1.4 |
Component: | plugin | Version: | 1.3.2 |
Keywords: | [autocomplete] highlight | Cc: | |
Blocked by: | Blocking: |
Description
Using firebug, I'm able to determine that the regex used in $.Autocompleter.defaults highlight parameter function is faulty and doing a character by character replacement of itself prepended by <strong></strong> when var term is empty. For example we expect:
<ul style="overflow: auto; max-height: 180px;">
<li class="ac_even ac_over">
<strong>FooBar</strong>
</li>
</ul>
But instead we get:
<ul style="overflow: auto; max-height: 180px;">
<li class="ac_even ac_over">
<strong/>
F
<strong/>
o
<strong/>
o
<strong/>
B
<strong/>
a
<strong/>
r
<strong/>
</li>
</ul>
Suggested code edit starting at line 408:
highlight: function(value, term) {
if ("" != term) {
return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + term.replace(/([\\^\\$\\(\\)\\[\\]\\{\\}\\*\\.\\+\\?\\|\\\\])/gi, "\\\\$1") + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>");
} else {
return value;
}
Attachments (0)
Change History (2)
Changed June 02, 2009 12:52AM UTC by comment:1
Changed October 12, 2009 11:59PM UTC by comment:2
resolution: | → invalid |
---|---|
status: | new → closed |
This is not a jQuery core bug. Please report plugin bugs to the plugin's author, or ask on the jQuery forums. jQuery UI bugs should be reported on the UI bug tracker, http://dev.jqueryui.com .
A related fix may be to change the last "gi" parameter to "i" which will match only the first character.
I noticed that if your first character is repeated, then all instances get bolded, which is missleading since only the first character is matched (after you've typed only 1 char).
For example "Fluffy" would have 3 bold "f"'s after typing "f". After changing "gi" to "i", only the first F is bold. This is better since typing "fy" or "ffy" does *not* match Fluffy.