UNPKG

@csstools/postcss-random-function

Version:
2 lines (1 loc) 428 B
"use strict";var e=require("@csstools/css-calc");const s=/(?<![-\w])(?:random)\(/i,creator=o=>{const c=Object.assign({preserve:!1},o);return{postcssPlugin:"postcss-random-function",Declaration(o){if(!s.test(o.value))return;const r=e.calc(o.value,{precision:5,toCanonicalUnits:!0,randomSeed:o.source?.input.css.length});r!==o.value&&(o.cloneBefore({value:r}),c.preserve||o.remove())}}};creator.postcss=!0,module.exports=creator;