2
0
mirror of https://github.com/devbridge/jQuery-Autocomplete.git synced 2024-11-22 12:55:12 +00:00

JS - Replace 'foo.length === 0' by '!foo.length'

Saving few bytes by replacing 'foo.length === 0' by '!foo.length' in JavaScript code
This commit is contained in:
stonio 2016-07-06 16:53:00 +02:00 committed by GitHub
parent 56c352ab01
commit b09eab6629

View File

@ -158,7 +158,7 @@
that.element.setAttribute('autocomplete', 'off');
that.killerFn = function (e) {
if ($(e.target).closest('.' + that.options.containerClass).length === 0) {
if (!$(e.target).closest('.' + that.options.containerClass).length) {
that.killSuggestions();
that.disableKillerFn();
}
@ -636,7 +636,7 @@
},
suggest: function () {
if (this.suggestions.length === 0) {
if (!this.suggestions.length) {
if (this.options.showNoSuggestionNotice) {
this.noSuggestions();
} else {
@ -804,7 +804,7 @@
// Cache results if cache is not disabled:
if (!options.noCache) {
that.cachedResponse[cacheKey] = result;
if (options.preventBadQueries && result.suggestions.length === 0) {
if (options.preventBadQueries && !result.suggestions.length) {
that.badQueries.push(originalQuery);
}
}
@ -962,7 +962,7 @@
var dataKey = 'autocomplete';
// If function invoked without argument return
// instance of the first matched element:
if (arguments.length === 0) {
if (!arguments.length) {
return this.first().data(dataKey);
}