Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: CSS font descriptors wrongly validated as font properties #1308

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
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
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
Loading