diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2023-10-14 15:05:55 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2023-10-14 15:05:55 +0800 |
| commit | c06f7ee0a40255214c477e13d9b956a7e07c2900 (patch) | |
| tree | f5982a568ef8fab865d0142e71c7494fea3e4c1b /node_modules/@csstools/postcss-nested-calc/dist/index.mjs | |
| parent | 3fd9400d4dccc25aa29b5702216732e0b7542073 (diff) | |
postcss,(plugins): nanocss, postcss-preset-env
Diffstat (limited to 'node_modules/@csstools/postcss-nested-calc/dist/index.mjs')
| -rw-r--r-- | node_modules/@csstools/postcss-nested-calc/dist/index.mjs | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/node_modules/@csstools/postcss-nested-calc/dist/index.mjs b/node_modules/@csstools/postcss-nested-calc/dist/index.mjs new file mode 100644 index 00000000..41363381 --- /dev/null +++ b/node_modules/@csstools/postcss-nested-calc/dist/index.mjs @@ -0,0 +1 @@ +import e from"postcss-value-parser";const t=/calc\(/gim;function hasFallback(e){const t=e.parent;if(!t)return!1;const r=t.index(e);for(let a=0;a<r;a++){const r=t.nodes[a];if("decl"===r.type&&r.prop.toLowerCase()===e.prop.toLowerCase())return!0}return!1}const creator=r=>{const a=Object.assign({preserve:!0},r);return{postcssPlugin:"postcss-nested-calc",Declaration(r,{result:o}){if((r.value.match(t)||[]).length<2)return;if(r.variable)return;if(hasFallback(r))return;const n=r.value;let s;try{s=e(n)}catch(e){return void r.warn(o,`Failed to parse value '${n}'. Leaving the original value intact.`)}if(void 0===s)return;e.walk(s.nodes,(t=>{t.type&&"function"===t.type&&"calc"===t.value.toLowerCase()&&e.walk(t.nodes,(e=>{if(e.type&&"function"===e.type)return"calc"===e.value.toLowerCase()&&void(e.value="")}))}),!0);const c=String(s);c!==n&&(r.cloneBefore({value:c}),a.preserve||r.remove())}}};creator.postcss=!0;export{creator as default}; |
