- Issue created by @just_like_good_vibes
- Merge request !3Issue #3500746 by just_like_good_vibes: Uncaught TypeError: n.trim is not a function → (Open) created by just_like_good_vibes
When used with a recent drupal11 site, the module is not working.
Indeed, jQuery is used in version 4.x.
Unfortunately, the JS code from mondialrelay seems not completely compatible with jquery 4.x,
in the sense there is at least the function "trim" which is used from the js code but absent in jquery 4.x
On my local site, i have altered the drupal/jquery library to add a small shim JS code like this :
if (typeof jQuery.trim === 'undefined') {
jQuery.trim = function(text) {
return text == null ? '' : String.prototype.trim.call(text);
};
}
i have defined this js code and added it to a library called "jquery_trim_shim" in my custom module "custom_module".
then i have implemented this hook in my custom module.
function custom_module_library_info_alter(&$libraries, $module) {
if ($module == 'core' && isset($libraries['jquery'])) {
//$libraries['jquery']['dependencies'][] = ' custom_module/jquery_trim_shim';
}
}
what do you think, should the "commerce_shipping_mondial_relay" adds this JS shim or does something else to still works under d11?
Active
1.0
Code