Skip to content

Commit

Permalink
fix: apply skipFonts option
Browse files Browse the repository at this point in the history
  • Loading branch information
bubkoo authored and istaiti committed Feb 7, 2023
1 parent 60ed161 commit 05ea041
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/embed-webfonts.ts
Expand Up @@ -227,15 +227,20 @@ export async function embedWebFonts<T extends HTMLElement>(
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)
}
}
}

0 comments on commit 05ea041

Please sign in to comment.