[FIX] mass_mailing, website: fix the weird spaces in rating snippet

To reproduce the issue:

-Drag and drop the rating snippet.
-Change the score from options.
-Notice that spaces between icons disappear.

In the release notes[1] of jQuery 3.5.0, it's stated that security
fixes related to the HTML parser were implemented. Consequently,
self-closing e.g. `<i/>` tags inside function arguments were replaced
with e.g. `<i></i>`. As a result, trailing spaces lost significance,
causing icons to stick together.

Before the commit:

Prior to Odoo 16.2, jQuery 3.3.1 was utilized, which allowed the use
of self-closing tags in the append function. This behavior was as
expected.However, starting from Odoo 16.2, jQuery version 3.6.3 was
adopted.

After the commit:

Instead of using self-closing `<i/>` tags, `<i></i> ` with a trailing
space was used. This trailing space gained significance due to the
prefilter no longer ignoring it. Consequently, icons no longer stick
together after changing the score.

task-3576760

[1] https://blog.jquery.com/2020/04/10/jquery-3-5-0-released/

closes odoo/odoo#161076

X-original-commit: b897e836697a288bbd58a8efc340d9f7b2e76e30
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
This commit is contained in:
Rahil Ghanchi
2024-04-09 19:35:40 +00:00
parent 565a5b1d4a
commit 1dbfd086f8
2 changed files with 4 additions and 4 deletions
@@ -111,9 +111,9 @@ options.registry.Rating = options.Class.extend({
this.$target.find('.s_rating_icons i').remove();
for (let i = 0; i < this.nbTotalIcons; i++) {
if (i < this.nbActiveIcons) {
$activeIcons.append('<i/> ');
$activeIcons.append('<i></i> ');
} else {
$inactiveIcons.append('<i/> ');
$inactiveIcons.append('<i></i> ');
}
}
this._renderIcons();
@@ -112,9 +112,9 @@ options.registry.Rating = options.Class.extend({
this.$target.find('.s_rating_icons i').remove();
for (let i = 0; i < this.nbTotalIcons; i++) {
if (i < this.nbActiveIcons) {
$activeIcons.append('<i/> ');
$activeIcons.append('<i></i> ');
} else {
$inactiveIcons.append('<i/> ');
$inactiveIcons.append('<i></i> ');
}
}
this._renderIcons();