Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function transpileVar(node, params) {
// css variable
const cssvar = node.nodes[1].value;
// css variable backup value
const backup = node.nodes[3];
if (cssvar in params) {
// conditionally transpile the css var() function into the matched param
node.replaceWith(
parser.word({ value: params[cssvar] })
);
} else if (backup) {
// conditionally transpile the css var() function into the backup value
node.replaceWith(backup);
}
}
node.nodes.slice(0).forEach(child => {
if (isColorModFunction(child)) {
// transform any variables within the color-mod() function
if (opts.transformVars) {
transformVariables(child, opts);
}
// transform any color-mod() functions
const color = transformColorModFunction(child, opts);
if (color) {
// update the color-mod() function with the transformed value
child.replaceWith(parser.word({
raws: child.raws,
value: opts.stringifier(color)
}));
}
} else if (child.nodes && Object(child.nodes).length) {
transformAST(child, opts);
}
});
}