Skip to content

Commit

Permalink
feat: [#1441] Support font-face
Browse files Browse the repository at this point in the history
  • Loading branch information
m-shaka committed Jul 1, 2024
1 parent e6f9127 commit ee8b4fa
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/happy-dom/src/css/utilities/CSSParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import CSSKeyframesRule from '../rules/CSSKeyframesRule.js';
import CSSMediaRule from '../rules/CSSMediaRule.js';
import CSSContainerRule from '../rules/CSSContainerRule.js';
import CSSSupportsRule from '../rules/CSSSupportsRule.js';
import CSSFontFaceRule from '../rules/CSSFontFaceRule.js';
import SelectorParser from '../../query-selector/SelectorParser.js';

const COMMENT_REGEXP = /\/\*[\s\S]*?\*\//gm;
Expand Down Expand Up @@ -78,6 +79,14 @@ export default class CSSParser {
newRule.parentStyleSheet = parentStyleSheet;
cssRules.push(newRule);
parentRule = newRule;
} else if (selectorText.startsWith('@font-face')) {
const conditionText = selectorText.replace('@font-face', '');
const newRule = new CSSFontFaceRule();

newRule[PropertySymbol.cssText] = conditionText;
newRule.parentStyleSheet = parentStyleSheet;
cssRules.push(newRule);
parentRule = newRule;
} else if (selectorText.startsWith('@')) {
// Unknown rule.
// We will create a new rule to let it grab its content, but we will not add it to the cssRules array.
Expand Down

0 comments on commit ee8b4fa

Please sign in to comment.