fix JS console: shim jquery4-compat ($.type, $.proxy, ...) avant slick 1.8.1 — jQuery 4.0 (Drupal 11) a supprimé ces API, slick plantait avec 'i.type is not a function' et cassait les carrousels
Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @file
|
||||
* Shim de compatibilité jQuery 4 pour les librairies legacy du thème.
|
||||
*
|
||||
* Drupal 11 embarque jQuery 4.0, qui a supprimé des API utilisées par
|
||||
* slick 1.8.1 ($.type, $.proxy) -> "TypeError: i.type is not a function"
|
||||
* dans la console et carrousels cassés. Ce shim les restaure si absentes.
|
||||
*/
|
||||
(function ($) {
|
||||
if (typeof $ === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$.type) {
|
||||
var class2type = {};
|
||||
'Boolean Number String Function Array Date RegExp Object Error Symbol'.split(' ').forEach(function (name) {
|
||||
class2type['[object ' + name + ']'] = name.toLowerCase();
|
||||
});
|
||||
$.type = function (obj) {
|
||||
if (obj == null) {
|
||||
return obj + '';
|
||||
}
|
||||
return typeof obj === 'object' || typeof obj === 'function'
|
||||
? (class2type[Object.prototype.toString.call(obj)] || 'object')
|
||||
: typeof obj;
|
||||
};
|
||||
}
|
||||
|
||||
if (!$.proxy) {
|
||||
$.proxy = function (fn, context) {
|
||||
var args = Array.prototype.slice.call(arguments, 2);
|
||||
return function () {
|
||||
return fn.apply(context || this, args.concat(Array.prototype.slice.call(arguments)));
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
if (!$.isArray) {
|
||||
$.isArray = Array.isArray;
|
||||
}
|
||||
if (!$.isFunction) {
|
||||
$.isFunction = function (obj) { return typeof obj === 'function'; };
|
||||
}
|
||||
if (!$.trim) {
|
||||
$.trim = function (text) { return text == null ? '' : String(text).trim(); };
|
||||
}
|
||||
})(jQuery);
|
||||
Reference in New Issue
Block a user