[FIX] web_editor: restore 'title' attribute on 'we' element

Since a refactoring (it was working at some point), `title` attribute on `we`
elements would be lost when rendering actual DOM elements.

We had 2 occurences of `title` on `we` elements:
1. s_countdown > What Should Happ.. > Show Message > fa-eye icon has a title
   (in next version 13.2)
2. data-js `BackgroundPosition` (section) > fa-arrows has a title

Also, incoming Cookies Bar task/PR will add a title on 'Hide For' option.

closes odoo/odoo#43199

X-original-commit: 230a84edcea139bc7df44a4d1a27761e74038257
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit is contained in:
Romain Derie
2020-01-13 12:05:27 +00:00
parent 39c00a28df
commit 5476a4c0ed
@@ -21,14 +21,19 @@ var _t = core._t;
* @returns {HTMLElement} - the original 'el' argument
*/
function _addTitleAndAllowedAttributes(el, title, options) {
let tooltipEl = el;
if (title) {
const titleEl = _buildTitleElement(title);
tooltipEl = titleEl;
el.appendChild(titleEl);
}
if (options && options.classes) {
el.classList.add(...options.classes);
}
if (options && options.tooltip) {
tooltipEl.title = options.tooltip;
}
if (options && options.dataAttributes) {
for (const key in options.dataAttributes) {
el.dataset[key] = options.dataAttributes[key];
@@ -1854,6 +1859,7 @@ const SnippetOptionWidget = Widget.extend({
options: {
classes: el.classList,
dataAttributes: el.dataset,
tooltip: el.title,
childNodes: [...el.childNodes],
},
};