segmentio / myth

A CSS preprocessor that acts like a polyfill for future versions of the spec.
4.33k stars 131 forks source link

Unoptimised @keyframes generation #115

Closed BorderlessNomad closed 9 years ago

BorderlessNomad commented 9 years ago
@keyframes stretchdelay {
  0%, 40%, 100% { transform: scaleY(0.4) }  
  20% { transform: scaleY(1.0) }
}

Should be generating,

@-webkit-keyframes stretchdelay {
  0%, 40%, 100% {
    -webkit-transform: scaleY(0.4);
  }

  20% {
    -webkit-transform: scaleY(1.0);
  }
}

@keyframes stretchdelay {
  0%, 40%, 100% {
    transform: scaleY(0.4);
  }

  20% {
    transform: scaleY(1.0);
  }
}

However at the moment it generates,

@-webkit-keyframes stretchdelay {
  0%, 40%, 100% {
    -webkit-transform: scaleY(0.4);
    transform: scaleY(0.4);
  }

  20% {
    -webkit-transform: scaleY(1.0);
    transform: scaleY(1.0);
  }
}

@keyframes stretchdelay {
  0%, 40%, 100% {
    -webkit-transform: scaleY(0.4);
    transform: scaleY(0.4);
  }

  20% {
    -webkit-transform: scaleY(1.0);
    transform: scaleY(1.0);
  }
}

Since @-webkit-keyframes stretchdelay will not be considered in ordinary case; having transform: scaleY(0.4); is clearly redundant.

ai commented 9 years ago

This question is relevant to Autoprefixer. But this is rational decision in Autoprefixer, because -webkit-transform can be remove from Chrome before that @-webkit-keyframes.

ianstormtaylor commented 9 years ago

Thanks @ai!