[FIX] web: avoid popover crash in iframe
This commit solves a crash which can happen when a popover points to an element inside an iframe that has been removed from the DOM. In those cases, the element's ownerDocument does not have a defaultView. closes odoo/odoo#151235 X-original-commit: 1ccebdbd2fcc6875173b02a31d89f3c2e9ffbfec Signed-off-by: Samuel Degueldre (sad) <sad@odoo.com>
This commit is contained in:
@@ -145,8 +145,12 @@ Popover.props = {
|
||||
validate: (target) => {
|
||||
// target may be inside an iframe, so get the Element constructor
|
||||
// to test against from its owner document's default view
|
||||
const Element = target?.ownerDocument?.defaultView.Element;
|
||||
return Boolean(Element) && (target instanceof Element || target instanceof window.Element);
|
||||
const Element = target?.ownerDocument?.defaultView?.Element;
|
||||
return (
|
||||
(Boolean(Element) &&
|
||||
(target instanceof Element || target instanceof window.Element)) ||
|
||||
(typeof target === "object" && target?.constructor?.name?.endsWith("Element"))
|
||||
);
|
||||
},
|
||||
},
|
||||
slots: {
|
||||
|
||||
Reference in New Issue
Block a user