From e6f27b02685463be722cd09304b7116d5a250b5f Mon Sep 17 00:00:00 2001 From: bubkoo Date: Fri, 26 Aug 2022 12:20:15 +0800 Subject: [PATCH] fix: apply skipFonts option fix #93 re #310 --- src/embed-webfonts.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/embed-webfonts.ts b/src/embed-webfonts.ts index aedfa9ca..885bffcc 100644 --- a/src/embed-webfonts.ts +++ b/src/embed-webfonts.ts @@ -227,15 +227,20 @@ export async function embedWebFonts( const cssText = options.fontEmbedCSS != null ? options.fontEmbedCSS + : options.skipFonts + ? null : await getWebFontCSS(clonedNode, options) - const styleNode = document.createElement('style') - const sytleContent = document.createTextNode(cssText) - styleNode.appendChild(sytleContent) + if (cssText) { + const styleNode = document.createElement('style') + const sytleContent = document.createTextNode(cssText) - if (clonedNode.firstChild) { - clonedNode.insertBefore(styleNode, clonedNode.firstChild) - } else { - clonedNode.appendChild(styleNode) + styleNode.appendChild(sytleContent) + + if (clonedNode.firstChild) { + clonedNode.insertBefore(styleNode, clonedNode.firstChild) + } else { + clonedNode.appendChild(styleNode) + } } }