From 555442d37effd2c99f31222934636da1fd8b9f22 Mon Sep 17 00:00:00 2001 From: Thomas Marstrander Date: Wed, 5 Aug 2020 11:44:23 +0200 Subject: [PATCH] Change fallback to original jquery .load() if first arg is not a function --- js/jquery.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/js/jquery.js b/js/jquery.js index 1bfc3e3..4f34d75 100644 --- a/js/jquery.js +++ b/js/jquery.js @@ -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) */ - 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); + 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); } \ No newline at end of file