handle situation where body has been deleted

fixes https://github.com/bigskysoftware/htmx/issues/2710
This commit is contained in:
Carson Gross 2024-08-05 13:18:03 -06:00
parent 89dc9bea2e
commit ce46e436fd

7
dist/htmx.amd.js vendored
View File

@ -773,10 +773,13 @@ var htmx = (function() {
function bodyContains(elt) {
// IE Fix
const rootNode = elt.getRootNode && elt.getRootNode()
if (getDocument().body === null) {
return false;
}
if (rootNode && rootNode instanceof window.ShadowRoot) {
return getDocument().body.contains(rootNode.host)
return getDocument().body.contains(rootNode.host);
} else {
return getDocument().body.contains(elt)
return getDocument().body.contains(elt);
}
}