Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip highlight #1655

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/typeahead/dataset.js
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
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
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