Chore: Improve iframe height adjustment with optional chaining

This commit is contained in:
Ralph Slooten
2026-05-05 17:41:17 +12:00
parent 878c68bb49
commit 10430f7dce

View File

@@ -216,7 +216,7 @@ export default {
resizeIframe(el) {
const i = el.target;
if (typeof i.contentWindow.document.body.scrollHeight === "number") {
if (i.contentWindow?.document?.body) {
i.style.height = i.contentWindow.document.body.scrollHeight + 50 + "px";
}
},
@@ -226,10 +226,8 @@ export default {
return;
}
const h = document.getElementById("preview-html");
if (h) {
if (typeof h.contentWindow.document.body.scrollHeight === "number") {
h.style.height = h.contentWindow.document.body.scrollHeight + 50 + "px";
}
if (h?.contentWindow?.document?.body) {
h.style.height = h.contentWindow.document.body.scrollHeight + 50 + "px";
}
},