Change fallback to original jquery .load() if first arg is not a function

stable moodle-1.21
Thomas Marstrander 2020-08-05 11:44:23 +02:00
parent c472d5172d
commit 555442d37e
No known key found for this signature in database
GPG Key ID: 59D7F1EC8B90E9A6
1 changed files with 8 additions and 8 deletions

8
js/jquery.js vendored
View File

@ -5,18 +5,18 @@ H5P.jQuery = jQuery.noConflict(true);
H5P.jQuery.fn.__originalLoad = H5P.jQuery.load;
H5P.jQuery.fn.load = function (url, params, callback) {
if (typeof url === "string") {
return H5P.jQuery.fn.__originalLoad.apply(this, arguments);
}
/**
* NOTE:
* This is needed in order to support old libraries that uses the .load() function
* for elements in the deprecated jQuery way (elem.load(fn)), the correct way to do this
* now is elem.on('load', fn)
*/
if (typeof url === "function") {
console.warn('You are using a deprecated H5P library. Please upgrade!');
let args = Array.prototype.slice.call(arguments);
args.unshift('load');
return H5P.jQuery.fn.on.apply(this, args);
}
return H5P.jQuery.fn.__originalLoad.apply(this, arguments);
}