Skip to content

Commit

Permalink
fix: Allow embedded functions inside CSS function (postcss#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
impy88 committed Nov 19, 2020
1 parent f16d55c commit 9a7cd8b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,13 @@ test(
'calc(var(--xxx, var(--yyy))/2)',
);

test(
'nested var level (3rd-level) (#77, cssnano#880)',
testValue,
'calc(var(--xxx, var(--yyy, var(---zzz))) / 2)',
'calc(var(--xxx, var(--yyy, var(---zzz)))/2)',
);

test(
'should not throw an exception when unknow function exist in calc',
testValue,
Expand Down
2 changes: 1 addition & 1 deletion src/parser.jison
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

(\-(webkit|moz)\-)?calc\b return 'CALC';

[a-z][a-z0-9-]*\s*\((?:(?:\"(?:\\.|[^\"\\])*\"|\'(?:\\.|[^\'\\])*\')|\([^)]*\)|[^\(\)]*)*\) return 'FUNCTION';
[a-z][a-z0-9-]*\s*\((?:(?:\"(?:\\.|[^\"\\])*\"|\'(?:\\.|[^\'\\])*\')|\((?:[^)(]|\((?:[^)(]|\([^)(]*\))*\))*\)|[^\(\)]*)*\) return 'FUNCTION';

"*" return 'MUL';
"/" return 'DIV';
Expand Down

0 comments on commit 9a7cd8b

Please sign in to comment.