Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/contrib/highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,17 @@ var highlight = function($element, pattern) {
return $element.each(function() {
highlight(this);
});
};
};

/**
* removeHighlight fn copied from highlight v5 and
* edited to remove with() and pass js strict mode
*/
jQuery.fn.removeHighlight = function() {
return this.find("span.highlight").each(function() {
this.parentNode.firstChild.nodeName;
var parent = this.parentNode;
parent.replaceChild(this.firstChild, this);
parent.normalize();
}).end();
};
1 change: 1 addition & 0 deletions src/selectize.js
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,7 @@ $.extend(Selectize.prototype, {

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