You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
653 B
JavaScript
25 lines
653 B
JavaScript
/**
|
|
* This function removes any uses of CSS variables used as an alpha channel
|
|
*
|
|
* This is required for selectors like `:visited` which do not allow
|
|
* changes in opacity or external control using CSS variables.
|
|
*
|
|
* @param {import('postcss').Container} container
|
|
* @param {string[]} toRemove
|
|
*/
|
|
export function removeAlphaVariables(container, toRemove) {
|
|
container.walkDecls((decl) => {
|
|
if (toRemove.includes(decl.prop)) {
|
|
decl.remove()
|
|
|
|
return
|
|
}
|
|
|
|
for (let varName of toRemove) {
|
|
if (decl.value.includes(`/ var(${varName})`)) {
|
|
decl.value = decl.value.replace(`/ var(${varName})`, '')
|
|
}
|
|
}
|
|
})
|
|
}
|