Files
simply_cpq/website/node_modules/@mui/x-internals/domUtils/isHTMLElement.mjs
T
2026-08-07 21:39:30 +02:00

21 lines
652 B
JavaScript

import ownerWindow from '@mui/utils/ownerWindow';
/**
* Checks if a value is an HTMLElement, including elements from other iframes/realms.
*/
export function isHTMLElement(value) {
if (typeof window === 'undefined' || value == null) {
return false;
}
if (value instanceof HTMLElement) {
return true;
}
// Cross-realm: must be an element node (nodeType 1) from another window.
// The try/catch guards against detached/destroyed windows where accessing
// `.HTMLElement` on the owner window may throw.
try {
return value.nodeType === 1 && value instanceof ownerWindow(value).HTMLElement;
} catch {
return false;
}
}