tbela99/css

Integer values shouldn't be converted into scientific notation during minification

Closed this issue · 2 comments

Input CSS:

a {
  z-index: 100000;
}

Output CSS:

a {
  z-index: 1e5;
}

However this is invalid in both Chrome and Firefox.

From what I understand this is because z-index is either auto or integer: https://developer.mozilla.org/ru/docs/Web/CSS/z-index
integer type doesn't support scientific notation: https://developer.mozilla.org/en-US/docs/Web/CSS/integer
But the number type does: https://developer.mozilla.org/en-US/docs/Web/CSS/number

Two solutions come to mind:

  • Have an array of known properties that support the number type and check against it
  • Don't minify values that way

I would rather go for an exclusion list

fixed