You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
895 B

2 years ago
  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";
  10. Object.defineProperty(exports, "__esModule", {
  11. value: true
  12. });
  13. Object.defineProperty(exports, "removeAlphaVariables", {
  14. enumerable: true,
  15. get: ()=>removeAlphaVariables
  16. });
  17. function 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. }