mirror of
https://github.com/axllent/mailpit.git
synced 2025-12-24 00:22:27 +02:00
Fix: Prevent potential JavaScript errors caused by race condition
This commit is contained in:
@@ -185,17 +185,19 @@ export default {
|
|||||||
// delay 0.2s until vue has rendered the iframe content
|
// delay 0.2s until vue has rendered the iframe content
|
||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
let p = document.getElementById('preview-html')
|
let p = document.getElementById('preview-html')
|
||||||
if (p && typeof p.contentWindow.document.body != 'undefined') {
|
if (p && typeof p.contentWindow.document.body == 'object') {
|
||||||
// make links open in new window
|
try {
|
||||||
let anchorEls = p.contentWindow.document.body.querySelectorAll('a')
|
// make links open in new window
|
||||||
for (var i = 0; i < anchorEls.length; i++) {
|
let anchorEls = p.contentWindow.document.body.querySelectorAll('a')
|
||||||
let anchorEl = anchorEls[i]
|
for (var i = 0; i < anchorEls.length; i++) {
|
||||||
let href = anchorEl.getAttribute('href')
|
let anchorEl = anchorEls[i]
|
||||||
|
let href = anchorEl.getAttribute('href')
|
||||||
|
|
||||||
if (href && href.match(/^http/)) {
|
if (href && href.match(/^http/)) {
|
||||||
anchorEl.setAttribute('target', '_blank')
|
anchorEl.setAttribute('target', '_blank')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (error) { }
|
||||||
this.resizeIFrames()
|
this.resizeIFrames()
|
||||||
}
|
}
|
||||||
}, 200)
|
}, 200)
|
||||||
@@ -208,7 +210,9 @@ export default {
|
|||||||
|
|
||||||
resizeIframe(el) {
|
resizeIframe(el) {
|
||||||
let i = el.target
|
let i = el.target
|
||||||
i.style.height = i.contentWindow.document.body.scrollHeight + 50 + 'px'
|
if (typeof i.contentWindow.document.body.scrollHeight == 'number') {
|
||||||
|
i.style.height = i.contentWindow.document.body.scrollHeight + 50 + 'px'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
resizeIFrames() {
|
resizeIFrames() {
|
||||||
@@ -217,7 +221,9 @@ export default {
|
|||||||
}
|
}
|
||||||
let h = document.getElementById('preview-html')
|
let h = document.getElementById('preview-html')
|
||||||
if (h) {
|
if (h) {
|
||||||
h.style.height = h.contentWindow.document.body.scrollHeight + 50 + 'px'
|
if (typeof h.contentWindow.document.body.scrollHeight == 'number') {
|
||||||
|
h.style.height = h.contentWindow.document.body.scrollHeight + 50 + 'px'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user