[FIX] website,* : fix map on jquery arrays

Jquery find return an object instead of an array of element.
When you map on this object, the first callback element is
so the index and not the element. This commit fix wrong usages of
.map() used with Jquery.

closes odoo/odoo#124359

X-original-commit: b87dac213dcc8a197dc7c00245a392d1e4d86925
Signed-off-by: Géry Debongnie <ged@odoo.com>
This commit is contained in:
Pulinckx Pierre (PIPU)
2023-06-08 23:01:21 +02:00
parent 98cd8f90ad
commit 911e2a5df9
4 changed files with 4 additions and 4 deletions
@@ -10,7 +10,7 @@ publicWidget.registry.UnsplashBeacon = publicWidget.Widget.extend({
* @override
*/
start: function () {
var unsplashImages = this.$('img[src*="/unsplash/"]').map((img) => {
var unsplashImages = Array.from(this.$('img[src*="/unsplash/"]')).map((img) => {
// get image id from URL (`http://www.domain.com:1234/unsplash/xYdf5feoI/lion.jpg` -> `xYdf5feoI`)
return img.src.split('/unsplash/')[1].split('/')[0];
});
+1 -1
View File
@@ -123,7 +123,7 @@ function autocompleteWithPages(self, $input, options) {
* @param {jQuery} [$excluded]
*/
function onceAllImagesLoaded($element, $excluded) {
var defs = $element.find('img').addBack('img').map(img => {
var defs = Array.from($element.find("img").addBack("img")).map((img) => {
if (img.complete || $excluded && ($excluded.is(img) || $excluded.has(img).length)) {
return; // Already loaded
}
@@ -278,7 +278,7 @@ options.registry.gallery = options.Class.extend({
*/
slideshow: function () {
const imageEls = this._getImages();
const images = imageEls.map((img) => ({
const images = Array.from(imageEls).map((img) => ({
// Use getAttribute to get the attribute value otherwise .src
// returns the absolute url.
src: img.getAttribute('src'),
@@ -614,7 +614,7 @@ publicWidget.registry.websiteForumSpam = publicWidget.Widget.extend({
_onMarkSpamClick: function (ev) {
var key = this.$('.modal .tab-pane.active').data('key');
var $inputs = this.$('.modal .tab-pane.active input.form-check-input:checked');
var values = $inputs.map((o) => parseInt(o.value));
var values = Array.from($inputs).map((o) => parseInt(o.value));
return this._rpc({model: 'forum.post',
method: 'mark_as_offensive_batch',
args: [this.spamIDs, key, values],