Error in CSS compressor

Issue #206 resolved
Christian-W. Budde created an issue

While it might not be used that often, I still found an issue with the CSS compressor in file dwsCSSPack:

Consider this @media-Rule snippet:

@media only screen and (max-width: 600px) {
  body {
    background-color: lightblue;
  }
}

which is compressed by default to:

@media only screen and(max-width:600px){body{background-color:lightblue}}

However, the “and(max-width:…” is considered wrong by all browsers. (and is marked as critical in http://csslint.net/)

Looking into the source code, I found the following problematic line:

         '(' : begin
            if context.LastOut=' ' then
               Dec(context.OutPtr);
            Inc(context.InParams);
            context.Copy;
         end;

If I uncomment the if context.LastOut=' ' then Dec(context.OutPtr); it seems to be working fine and as expected. I just wonder about why it was put there in the first place.

Comments (2)

  1. Eric Grange repo owner

    It was put there by incorrectly assuming that space was unnecessary 🙂
    I have published the unit and the corresponding unit test (but it’s the first one right now)

  2. Log in to comment