fix: iframe load to ensure images are loaded

This commit is contained in:
Niklas von Hertzen 2021-07-13 19:09:33 +08:00
parent e29af58661
commit 2608ff278b

View File

@ -472,18 +472,15 @@ const iframeLoader = (iframe: HTMLIFrameElement): Promise<HTMLIFrameElement> =>
const documentClone = cloneWindow.document; const documentClone = cloneWindow.document;
cloneWindow.onload = cloneWindow.onload = iframe.onload = () => {
iframe.onload = cloneWindow.onload = iframe.onload = null;
documentClone.onreadystatechange = const interval = setInterval(() => {
() => { if (documentClone.body.childNodes.length > 0 && documentClone.readyState === 'complete') {
cloneWindow.onload = iframe.onload = documentClone.onreadystatechange = null; clearInterval(interval);
const interval = setInterval(() => { resolve(iframe);
if (documentClone.body.childNodes.length > 0 && documentClone.readyState === 'complete') { }
clearInterval(interval); }, 50);
resolve(iframe); };
}
}, 50);
};
}); });
}; };