Skip to content

Commit

Permalink
fix: continue instead of break if font family doesn't match when extr…
Browse files Browse the repository at this point in the history
…acting font face data
  • Loading branch information
qwerzl committed Mar 21, 2024
1 parent 57fdded commit 9158263
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/css/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const styleMap: Record<string, string> = {
export function extractFontFaceData (css: string, family?: string): NormalizedFontFaceData[] {
const fontFaces: NormalizedFontFaceData[] = []

for (const node of findAll(parse(css), node => node.type === 'Atrule' && node.name === 'font-face')) {
loopNodes: for (const node of findAll(parse(css), node => node.type === 'Atrule' && node.name === 'font-face')) {
if (node.type !== 'Atrule' || node.name !== 'font-face') { continue }

const data: Partial<NormalizedFontFaceData> = {}
Expand All @@ -44,7 +44,7 @@ export function extractFontFaceData (css: string, family?: string): NormalizedFo
const value = extractCSSValue(child) as string | string[]
const slug = family.toLowerCase()
if (typeof value === 'string' && value.toLowerCase() !== slug) {
return []
continue loopNodes
}
if (Array.isArray(value) && value.length > 0 && value.every(v => v.toLowerCase() !== slug)) {
return []
Expand Down

0 comments on commit 9158263

Please sign in to comment.