diff --git a/src/__tests__/index.js b/src/__tests__/index.js index 2293653..a585478 100644 --- a/src/__tests__/index.js +++ b/src/__tests__/index.js @@ -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, diff --git a/src/parser.jison b/src/parser.jison index eb402b8..00946e1 100644 --- a/src/parser.jison +++ b/src/parser.jison @@ -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';