Uploaded image for project: 'Tapestry 5'
  1. Tapestry 5
  2. TAP5-2753

CssCompressor for CSS files produces wrong minification if calc contains variables.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 5.8.2
    • 5.8.3
    • tapestry-webresources
    • None

    Description

      CssCompressor for CSS files produces wrong minification if calc contains variables.

      .some-class
      {
      padding-top: calc(10px + var(--default-page-header-height));
      }
      

      produces spaces between dashes within the variable:

      .some-class
      {
      padding-top: calc(10px + var( - - default - page - header - height));
      }
      

      Just removing this code block at the end helps:

      // Add spaces back in between operators for css calc function
      // https://developer.mozilla.org/en-US/docs/Web/CSS/calc
      // Added by Eric Arnol-Martin (earnolmartin@gmail.com)
      sb = new StringBuffer();
      p = Pattern.compile("calc\\([^\\)]*\\)");
      m = p.matcher(css);
      while (m.find()) {
          String s = m.group();
          
          s = s.replaceAll("(?<=[-|%|px|em|rem|vw|\\d]+)\\+", " + ");
          s = s.replaceAll("(?<=[-|%|px|em|rem|vw|\\d]+)\\-", " - ");
          s = s.replaceAll("(?<=[-|%|px|em|rem|vw|\\d]+)\\*", " * ");
          s = s.replaceAll("(?<=[-|%|px|em|rem|vw|\\d]+)\\/", " / ");
          
          m.appendReplacement(sb, s);
      }
      m.appendTail(sb);
      css = sb.toString(); 
      

      Attachments

        Issue Links

          Activity

            People

              ben-ng Ben Weidig
              lrein LRein
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: