[FIX] web_editor: prevent traceback on select image

Trying to select the contents of a content-less element should select
the element itself instead.

closes odoo/odoo#69173

X-original-commit: 6905eaad2ccaa782e3dce99b9581ed0194c37db9
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit is contained in:
Antoine Guenet
2021-04-13 12:30:39 +00:00
parent 500ebb0687
commit 386875cf3d
@@ -78,6 +78,9 @@ $.fn.extend({
return this;
},
selectContent: function () {
if (this.length && !this[0].hasChildNodes()) {
return this.selectElement();
}
if (this.length) {
const selection = document.getSelection();
selection.removeAllRanges();