fix(font load): fix when font load timeout

This commit is contained in:
kete 2022-01-18 15:43:08 +08:00
parent d355366724
commit 24688ac608

View File

@ -109,8 +109,18 @@ export class DocumentCloner {
return Promise.reject(`Error finding the ${this.referenceElement.nodeName} in the cloned document`);
}
if (documentClone.fonts && documentClone.fonts.status === 'loading' && documentClone.fonts.ready) {
await documentClone.fonts.ready;
if (documentClone.fonts && documentClone.fonts.status === 'loading') {
return Promise.race([
documentClone.fonts.ready,
new Promise<void>((resolve) => {
const fontLoadTimer = setInterval(() => {
if (documentClone.fonts.status === 'loaded') {
clearInterval(fontLoadTimer);
resolve();
}
}, 1000);
})
]);
}
if (/(AppleWebKit)/g.test(navigator.userAgent)) {