Skip to content
Open
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
1 change: 1 addition & 0 deletions src/typeahead/dataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ var Dataset = (function() {

this.highlight && highlight({
className: this.classes.highlight,
skipHighlight: this.classes.skipHighlight,
node: fragment,
pattern: query
});
Expand Down
21 changes: 12 additions & 9 deletions src/typeahead/highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@

// inspired by https://github.com/jharding/bearhug

var highlight = (function(doc) {
var highlight = (function (doc) {
'use strict';

var defaults = {
node: null,
pattern: null,
tagName: 'strong',
className: null,
wordsOnly: false,
caseSensitive: false
};
node: null,
pattern: null,
tagName: 'strong',
className: null,
skipHighlight: null,
wordsOnly: false,
caseSensitive: false
};

return function hightlight(o) {
var regex;
Expand Down Expand Up @@ -57,7 +58,9 @@ var highlight = (function(doc) {
for (var i = 0; i < el.childNodes.length; i++) {
childNode = el.childNodes[i];

if (childNode.nodeType === TEXT_NODE_TYPE) {
if ($(childNode).hasClass(o.skipHighlight)) {
continue;
} else if (childNode.nodeType === TEXT_NODE_TYPE) {
i += hightlightTextNode(childNode) ? 1 : 0;
}

Expand Down
3 changes: 2 additions & 1 deletion src/typeahead/www.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ var WWW = (function() {
empty: 'tt-empty',
open: 'tt-open',
cursor: 'tt-cursor',
highlight: 'tt-highlight'
highlight: 'tt-highlight',
skipHighlight: 'tt-skip-highlight'
};

return build;
Expand Down