[FIX] web_editor: not fail when clicking on a technical SVG
Since [1] when the stars were made available in the power box, an exception is raised when clicking on a technical SVG of the "Steps" block. This happens because SVGs have their `nodeType === Node.ELEMENT_NODE`, they have `className` and `classList` properties, but their `className` is not a string: it is an `SVGAnimatedString`. Because of this, the `includes` method is not available on `className`. This commit prevents the non-existing `includes` from being called. Steps to reproduce: - Drop a "Steps" block into the page. - Click on the column before the first step, at the same height as the steps icons. (There is an hidden SVG there containing the definition of the arrows head.) => Did raise an exception. [1]: https://github.com/odoo/odoo/commit/8266b978e1bfa5bedfaf1c4fcceadd26400fc85c task-2845963 X-original-commit: dbfbf264750a0760d4f2d96a1b7a13ea27472316 Part-of: odoo/odoo#96071
This commit is contained in:
@@ -3004,14 +3004,13 @@ export class OdooEditor extends EventTarget {
|
||||
}
|
||||
|
||||
// handle stars
|
||||
if (node.nodeType === Node.ELEMENT_NODE && node.className.includes('fa-star') &&
|
||||
const isStar = el => el.nodeType === Node.ELEMENT_NODE && (
|
||||
el.classList.contains('fa-star') || el.classList.contains('fa-star-o')
|
||||
);
|
||||
if (isStar(node) &&
|
||||
node.parentElement && node.parentElement.className.includes('o_stars')) {
|
||||
const previousStars = getAdjacentPreviousSiblings(node, sib => (
|
||||
sib.nodeType === Node.ELEMENT_NODE && sib.className.includes('fa-star')
|
||||
));
|
||||
const nextStars = getAdjacentNextSiblings(node, sib => (
|
||||
sib.nodeType === Node.ELEMENT_NODE && sib.className.includes('fa-star')
|
||||
));
|
||||
const previousStars = getAdjacentPreviousSiblings(node, isStar);
|
||||
const nextStars = getAdjacentNextSiblings(node, isStar);
|
||||
if (nextStars.length || previousStars.length) {
|
||||
const shouldToggleOff = node.classList.contains('fa-star') &&
|
||||
(!nextStars[0] || !nextStars[0].classList.contains('fa-star'));
|
||||
|
||||
Reference in New Issue
Block a user