UNPKG

895 BJavaScriptView Raw
1/**
2 * This function removes any uses of CSS variables used as an alpha channel
3 *
4 * This is required for selectors like `:visited` which do not allow
5 * changes in opacity or external control using CSS variables.
6 *
7 * @param {import('postcss').Container} container
8 * @param {string[]} toRemove
9 */ "use strict";
10Object.defineProperty(exports, "__esModule", {
11 value: true
12});
13Object.defineProperty(exports, "removeAlphaVariables", {
14 enumerable: true,
15 get: ()=>removeAlphaVariables
16});
17function removeAlphaVariables(container, toRemove) {
18 container.walkDecls((decl)=>{
19 if (toRemove.includes(decl.prop)) {
20 decl.remove();
21 return;
22 }
23 for (let varName of toRemove){
24 if (decl.value.includes(`/ var(${varName})`)) {
25 decl.value = decl.value.replace(`/ var(${varName})`, "");
26 }
27 }
28 });
29}