Fix custom font preloading sometimes not working (#2493)

It didn't work if both a reference to an external style sheet and
a description of a custom font are present in a style element.
This commit is contained in:
Hikaru Y 2023-05-11 13:10:29 +09:00 committed by GitHub
parent 3999c99af7
commit 5f02765bb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -94,9 +94,9 @@ function preloadFonts(fragment: DocumentFragment): Promise<void>[] {
export async function preloadResources(html: string): Promise<void> {
template.innerHTML = html;
const fragment = template.content;
const styleSheets = preloadStyleSheets(fragment);
const images = preloadImages(fragment);
const fonts = preloadFonts(fragment);
const styleSheets = preloadStyleSheets(fragment.cloneNode(true) as DocumentFragment);
const images = preloadImages(fragment.cloneNode(true) as DocumentFragment);
const fonts = preloadFonts(fragment.cloneNode(true) as DocumentFragment);
let timeout: number;
if (fonts.length) {