Skip to content

Commit

Permalink
Fix: Deprecated jQuery.isFunction()
Browse files Browse the repository at this point in the history
  • Loading branch information
Dernerd committed Dec 24, 2023
1 parent 0179c02 commit 32c3698
Show file tree
Hide file tree
Showing 9 changed files with 166 additions and 154 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -756,8 +756,7 @@
* @date 2011/08/17
* @id TextExtAutocomplete.onShowDropdown
*/
p.onShowDropdown = function(e, renderCallback)
{
p.onShowDropdown = function(e, renderCallback){
var self = this,
current = self.selectedSuggestionElement().data(CSS_SUGGESTION),
suggestions = self._suggestions
Expand All @@ -766,12 +765,10 @@
if(!suggestions)
return self.trigger(EVENT_GET_SUGGESTIONS);

if($.isFunction(renderCallback))
{
if (typeof renderCallback === "function") {
renderCallback(self);
}
else
{
else{
self.renderSuggestions(self._suggestions);
self.toggleNextSuggestion();
}
Expand Down
48 changes: 26 additions & 22 deletions includes/psource-metaboxes/ui/select2/select2.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
Copyright 2012 Igor Vaynberg
Copyright 2024 DerN3rd
Version: 3.5.0 Timestamp: Mon Jun 16 19:29:44 EDT 2014
Version: 3.5.1
This software is licensed under the Apache License, Version 2.0 (the "Apache License") or the GNU
General Public License version 2 (the "GPL License"). You may choose either license to govern your
Expand Down Expand Up @@ -428,7 +428,7 @@ the specific language governing permissions and limitations under the Apache Lic
if (handler && typeof handler.abort === "function") { handler.abort(); }

if (options.params) {
if ($.isFunction(options.params)) {
if (typeof options.params === "function") {
$.extend(params, options.params.call(self));
} else {
$.extend(params, options.params);
Expand Down Expand Up @@ -471,21 +471,21 @@ the specific language governing permissions and limitations under the Apache Lic
tmp,
text = function (item) { return ""+item.text; }; // function used to retrieve the text portion of a data item that is matched against the search

if ($.isArray(data)) {
tmp = data;
data = { results: tmp };
}
if (Array.isArray(data)) {
tmp = data;
data = { results: tmp };
}

if ($.isFunction(data) === false) {
tmp = data;
data = function() { return tmp; };
}
if (typeof data !== "function") {
tmp = data;
data = function() { return tmp; };
}

var dataItem = data();
if (dataItem.text) {
text = dataItem.text;
// if text is not a function we assume it to be a key name
if (!$.isFunction(text)) {
if (typeof text !== "function") {
dataText = dataItem.text; // we need to store this in a separate variable because in the next step data gets reset and data.text is no longer available
text = function (item) { return item[dataText]; };
}
Expand Down Expand Up @@ -525,7 +525,7 @@ the specific language governing permissions and limitations under the Apache Lic

// TODO javadoc
function tags(data) {
var isFunc = $.isFunction(data);
var isFunc = typeof data === "function";
return function (query) {
var t = query.term, filtered = {results: []};
var result = isFunc ? data(query) : data;
Expand All @@ -551,7 +551,9 @@ the specific language governing permissions and limitations under the Apache Lic
* @param formatter
*/
function checkFormatter(formatter, formatterName) {
if ($.isFunction(formatter)) return true;
if (typeof formatter === "function") {
return true;
}
if (!formatter) return false;
if (typeof(formatter) === 'string') return true;
throw new Error(formatterName +" must be a string, function, or falsy value");
Expand All @@ -566,7 +568,7 @@ the specific language governing permissions and limitations under the Apache Lic
* @returns {*}
*/
function evaluate(val, context) {
if ($.isFunction(val)) {
if (typeof val === "function") {
var args = Array.prototype.slice.call(arguments, 2);
return val.apply(context, args);
}
Expand Down Expand Up @@ -801,7 +803,7 @@ the specific language governing permissions and limitations under the Apache Lic

this.nextSearchTerm = undefined;

if ($.isFunction(this.opts.initSelection)) {
if (typeof this.opts.initSelection === "function") {
// initialize selection based on the current value of the source element
this.initSelection();

Expand Down Expand Up @@ -1049,7 +1051,9 @@ the specific language governing permissions and limitations under the Apache Lic
$(splitVal(element.val(), opts.separator)).each(function () {
var obj = { id: this, text: this },
tags = opts.tags;
if ($.isFunction(tags)) tags=tags();
if (typeof tags === "function") {
tags = tags();
}
$(tags).each(function() { if (equal(this.id, obj.id)) { obj = this; return false; } });
data.push(obj);
});
Expand Down Expand Up @@ -1906,7 +1910,7 @@ the specific language governing permissions and limitations under the Apache Lic
}

return null;
} else if ($.isFunction(this.opts.width)) {
} else if (typeof this.opts.width === "function") {
return this.opts.width();
} else {
return this.opts.width;
Expand Down Expand Up @@ -2317,9 +2321,9 @@ the specific language governing permissions and limitations under the Apache Lic
}
return is_match;
},
callback: !$.isFunction(callback) ? $.noop : function() {
callback: typeof callback === 'function' ? function() {
callback(match);
}
} : $.noop,
});
};
}
Expand Down Expand Up @@ -2589,7 +2593,7 @@ the specific language governing permissions and limitations under the Apache Lic
}
return is_match;
},
callback: !$.isFunction(callback) ? $.noop : function() {
callback: typeof callback === 'function' ? function() {
// reorder matches based on the order they appear in the ids array because right now
// they are in the order in which they appear in data array
var ordered = [];
Expand All @@ -2605,7 +2609,7 @@ the specific language governing permissions and limitations under the Apache Lic
}
}
callback(ordered);
}
} : $.noop
});
};
}
Expand Down
2 changes: 1 addition & 1 deletion includes/psource-metaboxes/ui/select2/select2.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Halte Dich mit unserem [Newsletter](https://n3rds.work/webmasterservice-n3rdswor
* Fix: Deprecated .change()
* Fix: Deprecated .blur()
* Fix: Deprecated .bind()
* Fix: Deprecated jQuery.isFunction()

= 3.5.6 =

Expand Down
Loading

0 comments on commit 32c3698

Please sign in to comment.