From 6e39e31030c28a8eb09ddcd93ca9ca382b4f6f10 Mon Sep 17 00:00:00 2001 From: "Arthur Detroux (ard)" Date: Tue, 9 Apr 2024 08:56:24 +0200 Subject: [PATCH] [FIX] web: allow the usage of .at in lower versions of Safari Commit [1] refactored the mail code and introduced a few .at called on Array typed objects. This is not supported in lower versions of iOS which some of our users and visitors still use as shown by [2]. This commit introduces a polyfill to support the feature on Safari <=15.3. [1]: https://github.com/odoo/odoo/commit/631ae1c4d865b912a59ddc8a068bdbf2dedd6a04 [2]: https://github.com/odoo/odoo/issues/142022 opw-3824593 closes odoo/odoo#160758 Signed-off-by: Romain Derie (rde) --- addons/web/__manifest__.py | 1 + addons/web/static/src/polyfills/array.js | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 addons/web/static/src/polyfills/array.js diff --git a/addons/web/__manifest__.py b/addons/web/__manifest__.py index 7015f7cebcf..919fda1229a 100644 --- a/addons/web/__manifest__.py +++ b/addons/web/__manifest__.py @@ -124,6 +124,7 @@ This module provides the core of the Odoo Web Client. ], 'web.assets_frontend_minimal': [ 'web/static/src/polyfills/object.js', + 'web/static/src/polyfills/array.js', 'web/static/src/module_loader.js', 'web/static/src/session.js', 'web/static/src/core/browser/cookie.js', diff --git a/addons/web/static/src/polyfills/array.js b/addons/web/static/src/polyfills/array.js new file mode 100644 index 00000000000..cff897c1792 --- /dev/null +++ b/addons/web/static/src/polyfills/array.js @@ -0,0 +1,8 @@ +if (!Array.prototype.at) { + Array.prototype.at = function (index) { + if (index >= 0) { + return this[index]; + } + return this[this.length + index]; + }; +}