diff --git a/lib/variables.js b/lib/variables.js index 95c79cc..01647bd 100644 --- a/lib/variables.js +++ b/lib/variables.js @@ -12,28 +12,22 @@ const uniqueString = (string) => { */ export const replaceVariables = (el, value) => { - // find non-nested css function calls - // eg: rgb(...), drop-shadow(...) - const funcReg = /([a-z\-]+)\s*\(\s*([^\(\)]*?)\s*(?:,\s*([^\(\)]*?)\s*)?\s*\)/i; const replacements = []; - let match; const uniq = uniqueString(value); + let funcReg = /([a-z\-]+)\s*\(\s*([^,\(\)]*)\s*(?:,\s*([^,\(\)]*)\s*)?\)/i; + let match; while ((match = funcReg.exec(value)) !== null) { const i = `${replacements.length}`; - // attempt to resolve variables if (match[1].toLowerCase() == 'var') { const varValue = findVariableValue(el, match[2]); - // found variable value if (varValue) { value = value.replace(match[0], varValue); continue; } - // use default value - // var(--name , default-value) if (match[3]) { value = value.replace(match[0], match[3]); continue;