Skip to content

Commit

Permalink
fix: Error with undefined CSS variables in calc expression in shortha…
Browse files Browse the repository at this point in the history
…nd property

- fix #1028
  • Loading branch information
MurakamiShinyu committed Oct 21, 2022
1 parent c0b5fca commit db948cb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/core/src/vivliostyle/css-cascade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4400,11 +4400,15 @@ export class CalcFilterVisitor extends Css.FilterVisitor {
return value;
}
const exprText = value.toString().replace(/^calc\b/, "-epubx-expr");
if (/\d(%|em|ex|cap|ch|ic|lh|p?v[whbi]|p?vmin|p?vmax)\W/i.test(exprText)) {
if (
/\d(%|em|ex|cap|ch|ic|lh|p?v[whbi]|p?vmin|p?vmax)\W|\Wvar\(\s*--/i.test(
exprText,
)
) {
return value;
}
const exprVal = CssParser.parseValue(
null,
this.context.rootScope,
new CssTokenizer.Tokenizer(exprText, null),
"",
);
Expand Down

0 comments on commit db948cb

Please sign in to comment.