Skip to content

Commit 0dc92f2

Browse files
committed
Merge #1099
2 parents 457e420 + adac3ce commit 0dc92f2

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
* Fix highlighting more than one character (#1099, #1098)
2+
3+
*@skimi*
4+
5+
16
## v0.12.2 · 23 June 2016
27
* Fix issue preventing build ("Cannot assign to read only property
38
'subarray'") because of bug in uglifyjs. (#1072)

src/contrib/highlight.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,17 @@ var highlight = function($element, pattern) {
3636
return $element.each(function() {
3737
highlight(this);
3838
});
39-
};
39+
};
40+
41+
/**
42+
* removeHighlight fn copied from highlight v5 and
43+
* edited to remove with() and pass js strict mode
44+
*/
45+
jQuery.fn.removeHighlight = function() {
46+
return this.find("span.highlight").each(function() {
47+
this.parentNode.firstChild.nodeName;
48+
var parent = this.parentNode;
49+
parent.replaceChild(this.firstChild, this);
50+
parent.normalize();
51+
}).end();
52+
};

src/selectize.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,6 +1100,7 @@ $.extend(Selectize.prototype, {
11001100

11011101
// highlight matching terms inline
11021102
if (self.settings.highlight && results.query.length && results.tokens.length) {
1103+
$dropdown_content.removeHighlight();
11031104
for (i = 0, n = results.tokens.length; i < n; i++) {
11041105
highlight($dropdown_content, results.tokens[i].regex);
11051106
}

0 commit comments

Comments
 (0)