css-modules / postcss-icss-values

Pass arbitrary constants between your module files
MIT License
203 stars 18 forks source link

Nested parentheses breaks value definition regex #57

Closed alexanderchr closed 8 years ago

alexanderchr commented 8 years ago

@value primary: color(red lightness(10%));.

Outputs

:export { primary: color(red saturation(10%); }

Appears to be caused by const matchValueDefinition = /(?:,\s+|^)([\w-]+):?\s+("[^"]*"|'[^']*'|\w+\([^\)]+\)|[^,]+)\s?/g and especially the negation in \w+\([^\)]+\).

alexanderchr commented 8 years ago

The negation was added in https://github.com/css-modules/postcss-modules-values/commit/c24881e338f9857d2ecc91a4d10074b15d37552e to allow commas within parentheses.

Replacing [^\)]+ with .+ seems to work in this scenario and does not break any tests. Am i missing something obvious?