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

highlight matched letters case insensitive #71

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 76 additions & 76 deletions dist/horsey.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion dist/horsey.min.js

Large diffs are not rendered by default.

66 changes: 33 additions & 33 deletions horsey.es5.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,20 @@ var doc = document;
var docElement = doc.documentElement;

function horsey(el) {
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var setAppends = options.setAppends;
var _set = options.set;
var filter = options.filter;
var source = options.source;
var _options$cache = options.cache;
var cache = _options$cache === undefined ? {} : _options$cache;
var predictNextSearch = options.predictNextSearch;
var renderItem = options.renderItem;
var renderCategory = options.renderCategory;
var blankSearch = options.blankSearch;
var appendTo = options.appendTo;
var anchor = options.anchor;
var debounce = options.debounce;
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var setAppends = options.setAppends,
_set = options.set,
filter = options.filter,
source = options.source,
_options$cache = options.cache,
cache = _options$cache === undefined ? {} : _options$cache,
predictNextSearch = options.predictNextSearch,
renderItem = options.renderItem,
renderCategory = options.renderCategory,
blankSearch = options.blankSearch,
appendTo = options.appendTo,
anchor = options.anchor,
debounce = options.debounce;

var caching = options.cache !== false;
if (!source) {
Expand Down Expand Up @@ -116,8 +116,8 @@ function horsey(el) {
return data.query.length;
}
function sourceFunction(data, done) {
var query = data.query;
var limit = data.limit;
var query = data.query,
limit = data.limit;

if (!options.blankSearch && query.length === 0) {
done(null, [], true);return;
Expand Down Expand Up @@ -167,25 +167,25 @@ function horsey(el) {
}

function autocomplete(el) {
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

var o = options;
var parent = o.appendTo || doc.body;
var getText = o.getText;
var getValue = o.getValue;
var form = o.form;
var source = o.source;
var noMatches = o.noMatches;
var noMatchesText = o.noMatchesText;
var _o$highlighter = o.highlighter;
var highlighter = _o$highlighter === undefined ? true : _o$highlighter;
var _o$highlightCompleteW = o.highlightCompleteWords;
var highlightCompleteWords = _o$highlightCompleteW === undefined ? true : _o$highlightCompleteW;
var _o$renderItem = o.renderItem;
var renderItem = _o$renderItem === undefined ? defaultItemRenderer : _o$renderItem;
var _o$renderCategory = o.renderCategory;
var renderCategory = _o$renderCategory === undefined ? defaultCategoryRenderer : _o$renderCategory;
var setAppends = o.setAppends;
var getText = o.getText,
getValue = o.getValue,
form = o.form,
source = o.source,
noMatches = o.noMatches,
noMatchesText = o.noMatchesText,
_o$highlighter = o.highlighter,
highlighter = _o$highlighter === undefined ? true : _o$highlighter,
_o$highlightCompleteW = o.highlightCompleteWords,
highlightCompleteWords = _o$highlightCompleteW === undefined ? true : _o$highlightCompleteW,
_o$renderItem = o.renderItem,
renderItem = _o$renderItem === undefined ? defaultItemRenderer : _o$renderItem,
_o$renderCategory = o.renderCategory,
renderCategory = _o$renderCategory === undefined ? defaultCategoryRenderer : _o$renderCategory,
setAppends = o.setAppends;

var limit = typeof o.limit === 'number' ? o.limit : Infinity;
var userFilter = o.filter || defaultFilter;
Expand Down Expand Up @@ -571,7 +571,7 @@ function autocomplete(el) {

while (elems.length) {
var _el2 = elems.shift();
if ((_el2.innerText || _el2.textContent) === input) {
if ((_el2.innerText || _el2.textContent || '').toLocaleLowerCase() === input.toLocaleLowerCase()) {
on(_el2);
break;
} else {
Expand Down
2 changes: 1 addition & 1 deletion horsey.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ function autocomplete (el, options = {}) {
for (let input of needle) {
while (elems.length) {
let el = elems.shift();
if ((el.innerText || el.textContent) === input) {
if ((el.innerText || el.textContent || '').toLocaleLowerCase() === input.toLocaleLowerCase()) {
on(el);
break;
} else {
Expand Down