autoprefixer icon indicating copy to clipboard operation
autoprefixer copied to clipboard

Regression: -webkit-box-orient rules removed

Open Macil opened this issue 9 years ago • 45 comments

While upgrading my dependencies on a project with some pretty old css (and which includes some webkit-specific hacks), I noticed an issue. Autoprefixer version 6.7.0 now entirely removes "-webkit-box-orient" rules. Version 6.6.1 did not have this issue.

.foo {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-box-align: stretch;
}

->

.foo {
  display: -webkit-box;
  -webkit-box-align: stretch;
}

Here's the code I've tested with:

require('postcss')([require('postcss-cssnext')({browsers: 'chrome >= 42, safari >= 8'})]).process('.foo { display: -webkit-box; -webkit-box-orient: vertical; -webkit-box-align: stretch; }').css

Macil avatar Jan 25 '17 02:01 Macil

Is it a really issue if you ask Autoprefixer to remove old prefix? ;)

ai avatar Jan 25 '17 07:01 ai

@ai How to preserve -webkit-box-orient?

IharKrasnik avatar Jan 25 '17 13:01 IharKrasnik

Add any flexbox 2009 browser to browserslist in your package.json.

ai avatar Jan 25 '17 13:01 ai

Thank you

IharKrasnik avatar Jan 25 '17 13:01 IharKrasnik

@ai This still happens even if I add remove: false to the options.

Macil avatar Jan 25 '17 18:01 Macil

Are you sure that it does from Autoprefixer? Maybe some other tool (like minification in webpack’s css-loader) change file too?

ai avatar Jan 25 '17 23:01 ai

tested out with css-loader remain the same version, Autoprefixer is the only factor remains that causing this

yidea avatar Jan 26 '17 00:01 yidea

Oh, I was passing remove:false to postcss-cssnext. Passing it on to autoprefixer results in -webkit-box-orient not being removed.

var postcss = require('postcss');

var css = postcss([
  require('postcss-cssnext')({
    browsers: 'chrome >= 42, safari >= 8',
    features: {
      autoprefixer: {remove: false}
    }
  })
]).process(`
.foo {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-box-align: stretch;
}`).css;

console.log(css);

I thought the behavior of the (default) remove:true option was to only remove outdated rules if the modern rule was specified too. So that display:-webkit-flex;display:flex; -> display:flex; if possible, but display:-webkit-flex; alone would remain as display:-webkit-flex;. This case still seems to be the same. The -webkit-box-orient rules uniquely being stripped unconditionally is surprising to me, and I wonder if it really is intended or best given that it doesn't seem any other rules are treated like that.

Macil avatar Jan 26 '17 01:01 Macil

Disabling the remove option or adding a flexbox 2009 browser to browsers list are both fairly coarse workarounds for this type of scenario. Any interest in adding an option to opt-out of removal at the rule level?

jrowlingson avatar Jan 27 '17 20:01 jrowlingson

Extra option is not a solution, because most of developers will not read docs.

If you want to fix it, send a PR removing this hack https://github.com/postcss/autoprefixer/blob/master/lib/processor.coffee#L133

ai avatar Jan 27 '17 20:01 ai

@ai thanks - will do

jrowlingson avatar Jan 27 '17 21:01 jrowlingson

Possibly helpful for anyone reading up on this thread and problem, least intrusive option to prevent the removal of the line in question is to just disable the autoprefixer for this line/section

    /* autoprefixer: off */
    -webkit-box-orient: vertical;
    /* autoprefixer: on */

Lars-Weber avatar Apr 27 '17 14:04 Lars-Weber

@Lars-Weber best option is just add old Safari to browserslist config

ai avatar Apr 27 '17 18:04 ai

@Lars-Weber: awesome, thank you so much!

plamitgma avatar Jan 10 '18 03:01 plamitgma

@Lars-Weber @plamitgma /* autoprefixer: off|on */ doesn’t work like this. This comment disable/enable Autoprefxier for whole block, not for next lines.

ai avatar Jan 10 '18 03:01 ai

-webkit-box-orient: vertical can not be completed, you say"add old Safari to browserslist config". I do not know how to write it. Can you give a specific example? For beginners, please understand。 thank

shizitou avatar Mar 05 '18 02:03 shizitou

@shizitou create .browserslistrc file in your project root with this content:

defaults
Safari 6

ai avatar Mar 05 '18 11:03 ai

@Lars-Weber Works man. @ai

defaults Safari 6

not works man.

kmvan avatar Mar 26 '18 13:03 kmvan

@kmvan do you created Browsersllist config?

ai avatar Mar 26 '18 14:03 ai

@ai Yes. filename: .browserslistrc content:

defaults Safari 6

kmvan avatar Mar 26 '18 14:03 kmvan