mattbasta / crass

A CSS minifier and utility library for JavaScript
http://mattbasta.com/crass
MIT License
102 stars 6 forks source link

Possible issue with CSS3 Transition delay values of 0s #60

Closed Jac21 closed 7 years ago

Jac21 commented 7 years ago

Tested on latest versions of Chrome, Firefox and IE, utilizing the gulp-crass library, which is still on crass 0.7.5. Albeit, this occurs on the web-tool, which, if using the latest version of crass, would maintain the same issue as stated below.

From what I can tell, crass prefers to strip out suffixes of 0 value properties. This causes an issue wherein CSS transition delay values with a value of 0 become improperly formatted within the browser, e.g., this:

.card-reveal a:before {
  content: "";
  position: absolute;
  width: 100%;
  height: 2px;
  bottom: 0;
  left: 0;
  background-color: #ffab40;
  visibility: hidden;
  -webkit-transform: scaleX(0);
  -moz-transform: scaleX(0);
  -o-transform: scaleX(0);
  transform: scaleX(0);
  transition: all 0.3s ease-in-out 0s;
}

gets optimized to this:

.card-reveal a:before {
  -moz-transform: scalex(0);
  -o-transform: scalex(0);
  -webkit-transform: scalex(0);
  background-color: #ffab40;
  bottom: 0;
  content: "";
  height: 2px;
  left: 0;
  position: absolute;
  transform: scalex(0);
  transition: all 0.3s ease-in-out 0;
  visibility: hidden;
  width: 100%;
}

wherein the 's' of the transition delay of the transition: all 0.3s ease-in-out 0s; rule is done away with, resulting in the aforementioned improper CSS.

image

The workaround for this issue is to simply utilize a small value for the delay, i.e., 0.01s, in order to maintain the 's,' which suffices just fine in most scenarios.

mattbasta commented 7 years ago

Thanks for the report! I'll see what I can do.

mattbasta commented 7 years ago

This should be fixed in 0.11.1!