autoprefixer icon indicating copy to clipboard operation
autoprefixer copied to clipboard

Flex property with complex calc operation results in invalid CSS

Open meandmycode opened this issue 11 years ago • 4 comments

Just noticed this, I feel like this is a regression but I'll try bisect where this happened.

Given the following CSS:

.a {
  flex: calc((100% - 1.8em) / 2) 0 0;
}

The expected CSS would be something like this:

.a {
  -webkit-flex: calc((100% - 1.8em) / 2) 0 0;
      -ms-flex: calc((100% - 1.8em) / 2) 0 0;
          flex: calc((100% - 1.8em) / 2) 0 0;
}

However the resulting CSS is:

.a {
  -webkit-box-flex: calc((100%;
  -webkit-flex: calc((100% - 1.8em) / 2) 0 0;
      -ms-flex: calc((100% - 1.8em) / 2) 0 0;
          flex: calc((100% - 1.8em) / 2) 0 0;
}

Which causes the browsers parser to try and rescue what it can.

A work around is to override Autoprefixer like so:

.a {
  flex: calc((100% - 1.8em) / 2) 0 0;
  -webkit-box-flex: calc((100% - 1.8em) / 2) 0 0;
}

You can test this with the interactive demo here: http://simevidas.jsbin.com/gufoko/quiet

Thanks,

meandmycode avatar Jan 31 '15 19:01 meandmycode

Try to fix tomorrow. PostCSS has special module for correct parse of space delimited list.

ai avatar Jan 31 '15 19:01 ai

Thanks for the speedy response, certainly no rush from my point of view considering the work around is relatively simple.

meandmycode avatar Jan 31 '15 19:01 meandmycode

Fixed 5cc7f3bbd0214f3c7e4da34d546b3d383867cf1b

ai avatar Feb 01 '15 02:02 ai

Released in 5.1.1 version.

ai avatar Feb 01 '15 03:02 ai