Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/embed-webfonts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ async function parseWebFontRules<T extends HTMLElement>(
}

function normalizeFontFamily(font: string) {
return font.trim().replace(/["']/g, '')
return font?.trim().replace(/["']/g, '')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return font?.trim()?.replace(/["']/g, '')

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I'm not sure if it's needed, only font could be undefined. Trim and replace will not throw errors I guess if it's an empty string

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only undefined will throw exception, and there are the possibilities of font coming as undefined.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I cannot edit my code right now, I hope the maintainer could add this silent fail for fonts in a separate commit then

}

function getUsedFonts(node: HTMLElement) {
Expand Down
Loading