[FIX] web_editor: do not traceback on null selection
Because the `selectionchange` event is async, the selection can be null if the node has been removed between the moment the selection was moved and the moment the event is triggered. X-original-commit: 3232edb1ccb196c992f75858fe81d08a5af58ab9 Part-of: odoo/odoo#113540
This commit is contained in:
@@ -3580,6 +3580,12 @@ export class OdooEditor extends EventTarget {
|
||||
*/
|
||||
_onSelectionChange() {
|
||||
const selection = this.document.getSelection();
|
||||
if (!selection) {
|
||||
// Because the `selectionchange` event is async, the selection can
|
||||
// be null if the node has been removed between the moment the
|
||||
// selection was moved and the moment the event is triggered.
|
||||
return;
|
||||
}
|
||||
const anchorNode = selection.anchorNode;
|
||||
if (anchorNode && closestElement(anchorNode, '[data-oe-protected="true"]')) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user