Skip to content

Commit 4f59596

Browse files
authored
Merge pull request #865 from fschiettecatte/deprecations
Fixed JQuery 3.7.1 deprecation warnings
2 parents f97172f + 852e94b commit 4f59596

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

src/jquery.autocomplete.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
}
128128

129129
function _transformResult(response) {
130-
return typeof response === 'string' ? $.parseJSON(response) : response;
130+
return typeof response === 'string' ? JSON.parse(response) : response;
131131
}
132132

133133
function _formatResult(suggestion, currentValue) {
@@ -526,7 +526,7 @@
526526
return value;
527527
}
528528
parts = value.split(delimiter);
529-
return $.trim(parts[parts.length - 1]);
529+
return parts[parts.length - 1].trim();
530530
},
531531

532532
getSuggestionsLocal: function (query) {
@@ -567,7 +567,7 @@
567567

568568
params = options.ignoreParams ? null : options.params;
569569

570-
if ($.isFunction(options.lookup)) {
570+
if (typeof options.lookup === 'function') {
571571
options.lookup(q, function (data) {
572572
that.suggestions = data.suggestions;
573573
that.suggest();
@@ -579,7 +579,7 @@
579579
if (that.isLocal) {
580580
response = that.getSuggestionsLocal(q);
581581
} else {
582-
if ($.isFunction(serviceUrl)) {
582+
if (typeof serviceUrl === 'function') {
583583
serviceUrl = serviceUrl.call(that.element, q);
584584
}
585585
cacheKey = serviceUrl + '?' + $.param(params || {});
@@ -639,7 +639,7 @@
639639
var that = this,
640640
container = $(that.suggestionsContainer);
641641

642-
if ($.isFunction(that.options.onHide) && that.visible) {
642+
if ((typeof that.options.onHide === 'function') && that.visible) {
643643
that.options.onHide.call(that.element, container);
644644
}
645645

@@ -710,7 +710,7 @@
710710
noSuggestionsContainer.detach();
711711
container.html(html);
712712

713-
if ($.isFunction(beforeRender)) {
713+
if (typeof beforeRender === 'function') {
714714
beforeRender.call(that.element, container, that.suggestions);
715715
}
716716

@@ -747,7 +747,7 @@
747747
container.empty();
748748
container.append(noSuggestionsContainer);
749749

750-
if ($.isFunction(beforeRender)) {
750+
if (typeof beforeRender === 'function') {
751751
beforeRender.call(that.element, container, that.suggestions);
752752
}
753753

@@ -807,7 +807,7 @@
807807
if (that.hintValue !== hintValue) {
808808
that.hintValue = hintValue;
809809
that.hint = suggestion;
810-
if ($.isFunction(onHintCallback)) {
810+
if (typeof onHintCallback === 'function') {
811811
onHintCallback.call(that.element, hintValue);
812812
}
813813
}
@@ -825,7 +825,7 @@
825825
},
826826

827827
validateOrientation: function (orientation, fallback) {
828-
orientation = $.trim(orientation || '').toLowerCase();
828+
orientation = (orientation || '').trim().toLowerCase();
829829

830830
if ($.inArray(orientation, ['auto', 'bottom', 'top']) === -1) {
831831
orientation = fallback;
@@ -974,7 +974,7 @@
974974
that.suggestions = [];
975975
that.selection = suggestion;
976976

977-
if ($.isFunction(onSelectCallback)) {
977+
if (typeof onSelectCallback === 'function') {
978978
onSelectCallback.call(that.element, suggestion);
979979
}
980980
},

0 commit comments

Comments
 (0)