Skip to content

Commit 6ded59d

Browse files
skimijoallard
authored andcommitted
Fix highlight not working after first highlight insert #1098
1 parent 457e420 commit 6ded59d

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

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)