Skip to content

Commit

Permalink
Be a bit more resilient when -subfont-text cannot be found or has a d…
Browse files Browse the repository at this point in the history
…ifferent casing
  • Loading branch information
papandreou committed Jun 5, 2022
1 parent 4d6a789 commit a88f055
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/subsetFonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,16 @@ function groupTextsByFontFamilyProps(
props,
});
const firstRelation = availableFontFaceDeclarations[0].relations[0];
firstRelation.node.nodes
.find(
(childNode) =>
childNode.type === 'decl' && childNode.prop === '-subfont-text'
)
.remove();
const subfontTextNode = firstRelation.node.nodes.find(
(childNode) =>
childNode.type === 'decl' &&
childNode.prop.toLowerCase() === '-subfont-text'
);

firstRelation.from.markDirty();
if (subfontTextNode) {
subfontTextNode.remove();
firstRelation.from.markDirty();
}
}
if (text !== undefined) {
snappedTexts.push({
Expand Down

0 comments on commit a88f055

Please sign in to comment.