Skip to content

Commit

Permalink
Merge pull request #1308 from vivliostyle/fix/issue1307
Browse files Browse the repository at this point in the history
fix: CSS font descriptors wrongly validated as font properties
  • Loading branch information
MurakamiShinyu authored Apr 12, 2024
2 parents 13c1106 + 44f63fa commit d7140cd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions packages/core/src/vivliostyle/css-cascade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4361,6 +4361,7 @@ export class PropSetParserHandler
public readonly condition: Exprs.Val,
public readonly elementStyle: ElementStyle,
public readonly validatorSet: CssValidator.ValidatorSet,
public readonly ruleType?: string,
) {
super(scope, owner, false);
this.order = 0;
Expand Down
15 changes: 8 additions & 7 deletions packages/core/src/vivliostyle/css-validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2063,12 +2063,14 @@ export class ValidatorSet {
important: boolean,
receiver: PropertyReceiver,
): void {
if (Css.isCustomPropName(name)) {
receiver.simpleProperty(name, value, important);
return;
}
if (containsVar(value)) {
// Set the specified property containing `var(…)`
if (
Css.isCustomPropName(name) ||
// Check if it is a `@font-face` descriptor (Issue #1307)
(receiver as PropertyReceiver & { ruleType?: string }).ruleType ===
"font-face" ||
// Check if the property value containing `var(…)`
containsVar(value)
) {
receiver.simpleProperty(name, value, important);
return;
}
Expand Down Expand Up @@ -2101,7 +2103,6 @@ export class ValidatorSet {
} else if (!prefix && CSS.supports(name, value.toString())) {
// Browser supports this property value
receiver.simpleProperty(name, value, important);
return;
} else {
receiver.invalidPropertyValue(origName, value);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/vivliostyle/ops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2043,6 +2043,7 @@ export class BaseParserHandler extends CssCascade.CascadeParserHandler {
null,
properties,
this.masterHandler.validatorSet,
"font-face",
),
);
}
Expand Down

0 comments on commit d7140cd

Please sign in to comment.