Skip to content

fix: parse final font-face declarations without semicolons#475

Merged
tinchox5 merged 1 commit into
zumerlab:mainfrom
RexSkz:fix/font-face-declarations-without-semicolon
Jul 27, 2026
Merged

fix: parse final font-face declarations without semicolons#475
tinchox5 merged 1 commit into
zumerlab:mainfrom
RexSkz:fix/font-face-declarations-without-semicolon

Conversation

@RexSkz

@RexSkz RexSkz commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • parse all relevant @font-face declarations when the final declaration ends at } without a semicolon
  • share declaration extraction between font-face deduplication and external stylesheet processing
  • cover font-family, font-weight, font-style, font-stretch, and unicode-range

Testing

  • npx vitest run __tests__/module.fonts.test.js __tests__/module.fonts.more.test.js __tests__/module.fonts.more.more.test.js __tests__/module.fonts.katex.test.js __tests__/module.fonts.iframe.test.js --browser.headless --reporter=verbose
  • npx eslint src/modules/fonts.js __tests__/module.fonts.test.js
  • npm run test:types
  • npm run compile

@RexSkz
RexSkz force-pushed the fix/font-face-declarations-without-semicolon branch from 41b6871 to cd2b377 Compare July 27, 2026 02:30
@RexSkz

RexSkz commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

For additional context, this issue is especially visible with minified CSS. Minifiers may omit the semicolon after the final declaration in an @font-face block. When that final declaration is a descriptor other than src, the existing regular expressions fail to read it, so the face no longer matches the requested font variant and snapDOM does not embed or apply the font.

Until this PR is merged, I have worked around the issue in my project by placing src last in each @font-face block. The current parser already accepts src when it is terminated directly by }, which allows snapDOM to process the font correctly.

@tinchox5

Copy link
Copy Markdown
Member

Great proposal! Let me review and test it. Thank you

@tinchox5
tinchox5 merged commit f0ab5f5 into zumerlab:main Jul 27, 2026
@tinchox5

Copy link
Copy Markdown
Member

Released in v2.23.0. Thanks @RexSkz!

@RexSkz
RexSkz deleted the fix/font-face-declarations-without-semicolon branch July 27, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants